http://magician.ucsd.edu/essentials/webbookse112.html
look at the gradient section A.6
Thanks
There is no such thing as the slope of a point. There is a notion of the slope of a function along a direction, formally known as the directional derivative. Among the directional derivatives corresponding to directions with length 1, the maximum is achieved in the direction of the gradient.
So, do you want to compute the direction in which the function grows fastest (the gradient), or how fast it grows in that direction (the directional derivative in the direction of the gradient), or something else?
The former I assume?
Normals are -1 to 1 and wouldn't that be a derivative? So if you could please show both forms and I can try them both and see what the results are... and see if I like the results it shows?
Thanks
I am not done asking questions. :)
So you have a terrain described as a 2D heightmap. I assume that means you know the elevation of the terrain at the points of a grid. However, normals, gradients and all these things are only defined if you know the elevation of any point, not just the ones in the grid. You could use an interpolation method to extend the function to non-grid points in a reasonable manner, but perhaps this is beyond what you intend to do.
Alternatively, you can use discreet approximations to these things. If you do that, the gradient at (x,y) is simply the vector (height(x+1,y)-height(x,y), height(x,y+1)-height(x,y)).
Are we getting closer?