Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to seed a void map with "branches" of sine waves or any other waveform. Something like:

enter image description here

Know of any algorithm? Has to be one to generate trees or something like that.

share|improve this question
If you're looking for an actual tree rather than a non-uniform branching structure then you might like to look at L-Systems. Otherwise, you'll need to consider whether or not your tree structure is balanced, its depth and breadth limits, and whether or not branches can overlap. Does your root have to be in the center or at the bottom? Do branches have to follow some direction relative to their parent (i.e. always ending above the parent, or can they go anywhere)? – Martin Foot Dec 13 '11 at 20:44
Are you looking for a 2D or 3D algorithm? What do you mean by "small branches"? Why not just to use the approach you suggested with sinus functions spawned at certain random distances from each other? – Alexander Galkin Dec 13 '11 at 21:30
up vote 4 down vote accepted

What is the ultimate purpose of this algorithm supposed to be? Do you want to generate random roads? Branches for a tree? In 2D or 3D space?

The best approach might be to put a bunch of random points on the map, then do a minimum spanning tree. You can then use quadratic or cubic interpolation to make the lines curve into eachother.

Alternately, if you want to generate a tree-like structure in 3-space, you should investigate quaternion rotations, and rotating points about an abitrary axis.

share|improve this answer
2D, seed a map to generate a continent with MPD algorithm. This "tree" would be a mountain/s range. – Gabriel A. Zorrilla Dec 13 '11 at 22:57
By MPD you mean Mid Point Displacement? Is this for the purpose of constructing and efficient mesh? You might also want to look at:… - the source is on github – Gavan Woolery Dec 15 '11 at 0:12

If the your usage is creating landscape (or trees themselves) you can also look into fractal generating algorithms for example:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.