Help with this formula...

Started by
15 comments, last by MARS_999 11 years, 3 months ago

http://magician.ucsd.edu/essentials/webbookse112.html

look at the gradient section A.6

Thanks

Advertisement

I understand that section. It still doesn't tell me what you are trying to do.

find the slope of a point. Used for the normal on a 2d heightmap for terrain....

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?

If I have a grid say 64x64 then 0-63 in the x direction and 0-63 in the y direction, with each grid point holds the height(elevation) yes I know that data. That point could be anywhere from 0 to skys the limit.... :)

This topic is closed to new replies.

Advertisement