r-lib / isoband

isoband: An R package to generate contour lines and polygons.
https://isoband.r-lib.org
Other
130 stars 14 forks source link

Standardize isoline direction #4

Open clauswilke opened 5 years ago

clauswilke commented 5 years ago

It would be helpful if it was possible to standardize the isoline direction, such that "up" is always in a defined direction relative to the line. For example, going along the line, up is always on the right.

The marching squares algorithm produces lines with undefined direction, but as the lines are created we know where up and down is. One cheap way to get defined directions would be to keep track of the direction of each line segment (forwards/backwards), and at the end simply reverse all line segments that are backwards. The current code wasn't written with this in mind, so it may require some work, but at least in principle this should be doable.