Nearly, it's:

- Code: Select all
`gradient = rise / run = vertical change / horizontal change`

For a nice description of gradients, please refer to the Wikipedia entry for

slope. For what it's worth,

gradient is the formal mathematical terms for the first spatial derivative of a scalar field (e.g. a heightfield). 'Slope' or 'grade' are the colloquial/engineering equivalents. I don't know of any colloqual/engineering equivalents for

curvature (the second spatial derivative), but no matter, the formula is:

- Code: Select all
`curvature = gradient change / horizontal change`

To calculate the curvature over a step, you have to calculate the gradient at both ends of your step, take the difference, then divide by the length of the horizontal step. Always takes the absolute (i.e. positive) value, since it doesn't need to care about the direction of curvature. If you're calculating the curvature at a point on the map, this means calculating the average of the X and Y curvatures, which means you have to calculate four gradients.

Note however that most land types have zero parameters for curvature. It is seldom required to achieve the desired affect.

Cheerio,

Aaron.