javascript - How do I grow a PaperJS tree without crossed branches, and without it spasming? -
i'm trying use paperjs physics code generate dendrite-y tree shape of 350 nodes sprout out of single "origin" node.
i've been able of way there simulating 3 forces:
- springs between each node , parent
- tighter springs between each node , origin node, put nodes in concentric circles around origin node. nodes 1 generation 1 unit away origin, nodes 2 generations away 2 units, etc.
- gentle inverted gravity between nodes spread them out.
i add each node click of mouse. works great while, inevitably 2 things happen:
- a node sprouts such branch crosses branch. need avoid branches crossing.
- at 50 nodes, origin node starts vibrate. adding more nodes exacerbates condition. whole dendrite spasms violently and, after node or 2 added, disappears.
i'm stumped how solve these 2 problems. can advise?
code can viewed , run here. click "project index" on top row.
Comments
Post a Comment