Overview
This is a p5.js sketch that lays the foundation for exploring the modeling of meandering rivers (Wikipedia).
Specifically, this just establishes the data model and what I hope is a good initial state to explore actual meandering in subsequent sketches. The implementing PR includes diagrams of the data structures and smoothing approach.
Controls
Configuration:
(via the dat.gui control panel)
num_segmentshow many starting lines there are before smoothing takes placewave_amplitudenumber of pixels above and below the centerline the sine wave used to place the points will swing.wave_frequencythe number of sine-wave oscillations before the end point.source_headingthe direction of flow for head of the riversmooth_curvestoggles on/off the algorithmic smoothing of the curve.
Note: If you max out the num_segments you can see a clear depiction of the underlying sine-wave used for point generation. When the segment count is low, it is basically placing a point at the y coordinate along that wave for discrete x points (a sort of data-sampling effect).
References:
- Wikipedia: Meandering
Links:
Screenshot:


