[−][src]Function terr::heightmap::diamond_square
pub fn diamond_square<F, R: Rng, D: Distribution<F>>(
m: &mut Heightmap<F>,
n0: u32,
rng: &mut R,
distr: D
) -> Result<(), Error> where
F: RealField + Copy,
Perform diamond-square displacement on the given height-map.
Diamond-square displacement is a slightly improved variation of the mid-point displacement algorithm. Reference: Wikipedia.
The four corners of the heightmap should be initialised before performing mid-point displacement.
Parameters:
m
the heightmap (restricted to squares with side-length of2n + 1
)n0
(normally 0) is the number of midpoint displacement steps to skipdistr
is the displacement distribution; for example one may useUniform::new(-scale, scale)
orNormal::new(0.0, scale)
wherescale
is a scaling factor. Note that samples are multiplied by half the side length of the current quad.