April 23, 2018

Meandering

There has been a lot of research done on why rivers take the shape they do. I'm going to use a lot of that work to make my maps look better. I was tired of the simple, hex-locked straight lines. They work, yes, but they don't show me any interesting features.

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$).

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.