You’re right, doesn’t check the slope.
Hmmm, do you know an addon to get iso lines? You see what I mean?
Lines which are at same level in topologic maps.
Because if you can set the elevation step between 2 isolines, and have a segment (fixed distance to respect the slope angle depending on 2 isolines distance) maybe, by (programmatically) searching to link isolines with this segment, it could simply work.
Here’s an example:
If you have a 5.8m elevation between 2 isolines and you have a segment measuring 100m that starts at one isoline and join the next isoline above (from one vertex of the segment to the other without changing length), you basically draw a straight path with a 5.8% (3.3°) slope.
You might start from this new point to try to join the isoline above or continue on the isoline (take a curve for example).
Of course, it means that you might have a ditch under the segment, so you might add some gravel under your road or a bridge, or avoid this route.
2nd idea, an isoline with an angle (slope), starting at point A and ending at extremum (highest point before going down and back to A).
Like a series of planes starting at the top intersection with the landscape:
From there you have a boolean and only keep one side, so you could go helix or hair pin curves on one side of the mountain or mix both.
OK, you might have with some negative slopes. But they exist in life too.
No idea how to implement this in code though