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\$
2
  • \$\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\$ Dec 13, 2011 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\$ Dec 13, 2011 at 21:30

2 Answers 2

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\$
2
  • \$\begingroup\$ 2D, seed a map to generate a continent with MPD algorithm. This "tree" would be a mountain/s range. \$\endgroup\$
    – Gabriel
    Dec 13, 2011 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\$ Dec 15, 2011 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\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .