[][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 of 2n + 1)
  • n0 (normally 0) is the number of midpoint displacement steps to skip
  • distr is the displacement distribution; for example one may use Uniform::new(-scale, scale) or Normal::new(0.0, scale) where scale is a scaling factor. Note that samples are multiplied by half the side length of the current quad.