# Fractal 3D Tree (a Recursive Exercise)

**URL:** <https://discourse.slicer.org/t/fractal-3d-tree-a-recursive-exercise/27248>\
**Category:** Support\
**Tags:** python\
**Created:** [January 15, 2023, 10:55am UTC](https://discourse.slicer.org/t/fractal-3d-tree-a-recursive-exercise/27248 "2023-01-15T10:55:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [January 15, 2023, 10:55am UTC](https://discourse.slicer.org/t/fractal-3d-tree-a-recursive-exercise/27248/1 "2023-01-15T10:55:02Z")

</div>

![图片](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/f/6fa275ae0d6d17918716058b33d8ffb443d75f88.png)

 ![图片](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/2/225c60d6a028a705dbbff674f9c3c82202bef90e.png)

 ![图片](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/0/70a248a3da307d73420c11e660b5aa058f306921.png)

Just kidding…

---

<div class="post-metadata">

**Author:** ![RafaelPalomar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rafaelpalomar/32/1436_2.png) [@RafaelPalomar](https://discourse.slicer.org/u/RafaelPalomar)\
**Post date:** [January 16, 2023, 6:36am UTC](https://discourse.slicer.org/t/fractal-3d-tree-a-recursive-exercise/27248/2 "2023-01-16T06:36:50Z")

</div>

This type synthetic data could be useful for algorithm testing. Just out of curiosity, how did you generate it? Did you use 3D Slicer for the generation?

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [January 16, 2023, 4:22pm UTC](https://discourse.slicer.org/t/fractal-3d-tree-a-recursive-exercise/27248/3 "2023-01-16T16:22:35Z")

</div>

用python代码, 点到点产生棱柱, 继而以棱柱末端的点(这里是三棱柱-三个点)为起点, 以一定方向和距离再做棱柱, 如此递归…做了6层(3\*\*6), 末端的棱柱中点插入mark点, , ,

完成6层递归(产生将近1000个圆柱和728个markups点), 要花费20多分钟…

> Use python code in Slicer : generate a cylinder(`vtkcylindersource`) from point to point at first, and then use those points at the end of the cylinder (here is a triangular prism - three points) as starting points, and then make other cylinders in a certain direction and distance, so recursive Six layers (3 \* \* 6) are made, and the midpoints of the cylinders at the end is inserted into the `MarkupsFiducial`.

> It takes more than 20 minutes to complete 6 layers of recursion (generating nearly 1000 cylinders and 728 markups points)…
