I have a matrix of elevation values which could be said represents $h(x,y)$. I can obtain contours using this function that are like sides of hills, and I have a starting point and an end point.
How do I create a path from initial point toward end point by a) remaining on the same elevation level as much as possible (less climbing) and b) move towards the goal at the same time.
I would like to do this by utilizing multivariable calculus as much as possible. Can I take the diagonal direction of the gradient for example and combine it with a "goal direction" somehow that would give me a direction at each step? Maybe this could be an instance of heat flow where hills are a "denser material" which takes longer to heat up and easier path is around them, more direct?
I've seen approaches that define potential functions which create repelling potential and attracting potential and come up with a direction that way.
I liked the mathematics of this approach, in my case however the mountains are not 100% obstacles. I am looking for a similar approach in terms of localness, use of functions though.
We can assume $h(x,y)$ is a smooth manifold, differentiable everywhere, the discrete representation of the function would simply be a matrix, and it would be great to hear about discrete methods to solve a proposed solution as well.
Note: I will keep some links I come across below.
Repel-attract method http://portal.ku.edu.tr/~cbasdogan/Courses/Robotics/projects/algorithm_poten_field.pdf
Using the heat equation https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod/paper.pdf
Note: the final answer to this question will probably be here. This is more of a control theory problem.
If $\gamma : \Bbb R \to \Bbb R^2$ is a level curve of $h$, then then $h \circ \gamma$ is constant, and therefore its derivative is $0$: $$\frac {d(h\circ\gamma(t))}{dt} = \nabla h\cdot \dot \gamma(t) = 0$$
That is, the level curves always move perpendicular to the gradient. One such vector perpendicular to $\nabla h$ is $(h_y, -h_x)$. If we look at the flows of $(h_y, -h_x)$, then we have a set of level curves through every point. All other level curves are just reparameterizations $\gamma(g(t))$ for some $g : \Bbb R \to \Bbb R$.
In the discrete case, you estimate $h_x$ with $\Delta_x h = \dfrac{h(x + \Delta x,y) - h(x,y)}{\Delta x}$, and similarly for $\Delta_y h$. The horizontal direction is thus given by $h^\perp = (\Delta_y h, -\Delta_x h)$. But to control step size, it is helpful to normalize this (we only need a direction perpendicular to the gradient of $h$, not a particular vector). So, we define $$\hat h^\perp = \left(\frac{\Delta_y h}{\sqrt{\Delta_y h^2 + \Delta_x h^2}},\frac{-\Delta_x h}{\sqrt{\Delta_y h^2 + \Delta_x h^2}}\right)$$
Moving in this direction should be level. So if you start at $(x_0, y_0)$, and are moving with stepsize $s$, the next level point should be $$(x_0, y_0) + s\,\hat h^\perp$$