2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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)? \$\endgroup\$ – Martin Foot Dec 13 '11 at 20:44
  • \$\begingroup\$ 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? \$\endgroup\$ – Alexander Galkin Dec 13 '11 at 21:30
4
\$\begingroup\$

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.

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

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

http://en.wikipedia.org/wiki/Pythagoras_tree_(fractal)
en.wikipedia.org/wiki/Fractal

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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