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:

  1. springs between each node , parent
  2. 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.
  3. gentle inverted gravity between nodes spread them out.

i add each node click of mouse. works great while, inevitably 2 things happen:

  1. a node sprouts such branch crosses branch. need avoid branches crossing.
  2. 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

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -