# Moving Fractal Tree Space colonisation according to hand position (posenet)

**URL:** <https://discourse.processing.org/t/moving-fractal-tree-space-colonisation-according-to-hand-position-posenet/20737>\
**Category:** Libraries\
**Created:** [May 11, 2020, 8:10am UTC](https://discourse.processing.org/t/moving-fractal-tree-space-colonisation-according-to-hand-position-posenet/20737 "2020-05-11T08:10:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuinjann](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yuinjann](https://discourse.processing.org/u/yuinjann)\
**Post date:** [May 11, 2020, 8:10am UTC](https://discourse.processing.org/t/moving-fractal-tree-space-colonisation-according-to-hand-position-posenet/20737/1 "2020-05-11T08:10:36Z")

</div>

Hello! So I have this sketch that modifies Daniel Shiffman’s p5.js [[Coding Challenge #17: Fractal Trees - Space Colonization]](https://thecodingtrain.com/CodingChallenges/017-spacecolonizer.html). Using posenet, the leaves are generated by my left hand, and the root of the tree is generated on the right ( I eventually want to turn this into my right hand) The root grows to get the leaves.

Here is my sketch with a single tree.  
[https://editor.p5js.org/yuinjann/sketches/HAW1EsQrO](https://editor.p5js.org/yuinjann/sketches/HAW1EsQrO)

However, I want it so the whole tree, moves in the direction of the leaves (my hand), and the leaves are not stationary. ie, after the root reaches the leaves, it still can move. so the root value is constantly updating and can bend towards the position of the leaves, which is also updating and, which my left hand is controlling.

Here is an example of how it is right now: (so sorry for the bad drawing)

 ![Screenshot 2020-05-11 at 8.26.00 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a3bc8580ca1385ae265401503f6e01129e0276e8.jpeg)

you can see the leaves generated by the hand at one end, and the root starting at the other. once the root reaches a leaf, it stops moving. However, I want the tree to be able to keep bending and move according to where the red hand and thus red leaves, are.

 ![Screenshot 2020-05-11 at 8.26.08 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3f5bbaa3db0abd43058d971db2e95d947fff54d4.jpeg) ![Screenshot 2020-05-11 at 8.26.17 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/ccef29abc80ce5d80ea75eed4886d4bfb7187914.jpeg)

How might I do that? Is it changing the parent position each time? because a new branch is generated each time and stops when it reaches a leaf.

I made a version where the tree generates from my right hand,  
[https://editor.p5js.org/yuinjann/sketches/qPX57sbTC](https://editor.p5js.org/yuinjann/sketches/qPX57sbTC)  
but the past positions of the leaves are logged into an array, so its positions are not constantly updated, so it cant the direction of the whole tree.

I eventually want the tree to be generated from my right hand and the left hand controls the leaves and hence position of the roots of the trees. Let me know what I can do, thank you! Sorry if it’s so confusing.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 15, 2020, 12:44am UTC](https://discourse.processing.org/t/moving-fractal-tree-space-colonisation-according-to-hand-position-posenet/20737/2 "2020-05-15T00:44:21Z")

</div>

If I am understanding you right, I think that you want to update your tree branch locations using a reach / follow mechanic.

Look at these sketches for examples:

[https://p5js.org/examples/interaction-follow-2.html](https://p5js.org/examples/interaction-follow-2.html)  
[https://p5js.org/examples/interaction-follow-3.html](https://p5js.org/examples/interaction-follow-3.html)  
[https://p5js.org/examples/interaction-reach-2.html](https://p5js.org/examples/interaction-reach-2.html)  
[https://p5js.org/examples/interaction-reach-3.html](https://p5js.org/examples/interaction-reach-3.html)

There you will see all the segments in the array updating.

---

<div class="post-metadata">

**Author:** ![yuinjann](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yuinjann](https://discourse.processing.org/u/yuinjann)\
**Post date:** [May 15, 2020, 3:14am UTC](https://discourse.processing.org/t/moving-fractal-tree-space-colonisation-according-to-hand-position-posenet/20737/3 "2020-05-15T03:14:44Z")

</div>

ah perfect! thank you! 😃
