Space Colonization Algorithm
How to use
$ npm install pex-space-colonization
In your code:
var SpaceColon = require('pex-space-colonization')
var sc = new SpaceColon(optionsObject)
Then to iterate the algorithm:
var iterObject = sc.iterate()
The iterate object iterates the algorithm which basically means calcute the next step for every branch and eventually kill alive hormones. It returns an object which holds two arrays - buds and hormones.
Both arrays hold objects each having a x, y, z property. The most likley place you would want to call
iterate() is in your draw loop.
###restart() Restarts the algorithm. You can call this anytime.
The world is 3D so setting it to
'2d' basically sets all bud and hormone z parameters to 0
This options specifies the distance at which the bud can (or eat if you like) the hormone.
This is the step at which the buds move. Larger number = larger step.
This number determines how likely it for a branch to split on every step.
The number of hormones you start with. This is meaningless if you supply your own points. This is only for demo purpose when you let the algorithm generate hormones for you.
The number of buds you start with. This is meaningless if you supply your own points. This is only for demo purpose when you let the algorithm generate random buds for you.
The radius when the algorithm generates random points.
This is meaningless if you supply your own points.
If you supply your own bud points, this is where you pass them. Make sure you fill the array with objects each one having a x, y, z property
If you supply your own hormone points, this is where you pass them. Make sure you fill the array with objects each one having a x, y, z property
The angle at which the bud can look for hormones.
Type of growth. Split means everyime a branch splits into a new one it basically looks like a V. This is for tree-like structures. If its straight, then the original branch doesn't change direction, only the new branch goes sideways (looks like the top part of the letter K). This is used for leaf-like structures. It might be hard to understand this without vizualizing so just run the example and switch between the two.
The angle at which the branch splits.
The maximum distance at which the bud can look for hormones.
This code was originally based on the 2d implementation from Marcin Ignac (@vorg).
http://marcinignac.com/experiments/space-colonization/ His contribution to this library has been tremendous. The algorithm uses Marcin's vector library and the example uses his Pex WebGL library to draw out the result of the algorithm.