At first, I was just using spatial subdivision, but despite being fractal, it doesn't feel right for a river. So instead, I did way too much research on the science and modeling of real-world rivers.
I eventually settled (for now) on the model presented here:
\phi(\ell) = \omega \sin\left({2 \pi \ell \over L}\right)
x(t) = \int_0^t \cos \phi(\ell) \textrm{ d}\ell
x(t) = \int_0^t \sin \phi(\ell) \textrm{ d}\ell
t \in [0, L]
So far, not super complicated (for a parametric equation, that is). This is just the equation for a meander characterized by \omega \in [0, 120^\circ] on a horizontal line. To fit this meander to a line at an angle \theta, the following transformation is applied (there is also a transformation of length and width):
x'(t) = A {x(t) \over x(L)} \cos\theta - B {y(t) \over y(L/2)} \sin\theta
y'(t) = A {x(t) \over x(L)} \cos\theta + B {y(t) \over y(L/2)} \sin\theta
A = L/4, B = A/5
If \omega goes above about 120^\circ, the river will intersect itself. When this happens in real life, the river diverts through the shortest path (the point of intersection) and an oxbow lake is formed. I havne't implemented the code to make this a reality in the map yet, but I have to option to expand that in the future. For now, I've capped \omega < 120^\circ.
Technically speaking, \omega should be a function (at least partially) of the soil type and slope. Since I am not yet worried about soil types (not sure I'll ever be), I'm going to tie it directly to slope. Higher slopes mean less meander (smaller \omega).
Technically speaking, \omega should be a function (at least partially) of the soil type and slope. Since I am not yet worried about soil types (not sure I'll ever be), I'm going to tie it directly to slope. Higher slopes mean less meander (smaller \omega).
I'm still working on the elevation maps, so in lieu of using slope, I'll grab a random angle for \omega while I'm testing.
In future iterations, the scaling parameters will be functions of the underlying topography. In addition, my endpoints are merely the centers of each hex, shifted by a random amount in xy. I think I can use a little clever vector addition to make that look a bit more natural, but more on that later once I have my thoughts put together.
No comments:
Post a Comment