Trait libnoise::Generator2D
source · pub trait Generator2D: Generator<2> {
// Provided methods
fn rotate(self, rotation: [f64; 1]) -> Rotate<2, 1, Self> { ... }
fn displace_x<GA>(
self,
displacement_generator: GA
) -> Displace<2, 0, Self, GA>
where GA: Generator<2> { ... }
fn displace_y<GA>(
self,
displacement_generator: GA
) -> Displace<2, 1, Self, GA>
where GA: Generator<2> { ... }
}Expand description
A trait representing the specialization of Generator<D> for 2-dimensional input spaces.
Anything implementing this trait must also implement Generator<2>. This trait exists
for two reasons: The first is to provide functions that either only make sense for specific
dimensionalities, or are either too difficult or inefficient to implement in a
dimension-agnostic manner. The second is to bypass certain limitations of constant generics.
Provided Methods§
sourcefn rotate(self, rotation: [f64; 1]) -> Rotate<2, 1, Self>
fn rotate(self, rotation: [f64; 1]) -> Rotate<2, 1, Self>
Create a generator which rotates input points before passing them to the underlying generator.
Takes an angle in radians for each unique pair of axes in the input space and crates a generator which rotates each input point for the provided angle on the plane spanned by each axis pair, before passing it to the underlying generator. The specific plane of rotation for each angle is as follows:
| plane of rotation | corresponding angle |
|---|---|
xy-plane | rotation[0] |
Examples
Basic usage:
let point = [0.2, 0.5];
let generator = Source::simplex(42) // build a generator
.rotate([0.4]); // apply the adapter
let value = generator.sample(point); // sample the generatorsourcefn displace_x<GA>(self, displacement_generator: GA) -> Displace<2, 0, Self, GA>where
GA: Generator<2>,
fn displace_x<GA>(self, displacement_generator: GA) -> Displace<2, 0, Self, GA>where
GA: Generator<2>,
Create a generator providing the results of the underlying generator after displacing the x-coordinate by the result of the provided generator.
Creates a generator which is exactly the same as the underlying generator, except the
x-coordinate of the input point is first displaced by the result of displacement_generator
for that point.
Examples
Basic usage:
let mut point = [0.2, 0.5];
let generator = Source::simplex(42) // build a generator
.displace_x(Source::simplex(43)); // apply the adapter
let value = generator.sample(point); // sample the generator
point[0] += Source::simplex(43).sample(point);
assert_eq!(value, Source::simplex(42).sample(point))sourcefn displace_y<GA>(self, displacement_generator: GA) -> Displace<2, 1, Self, GA>where
GA: Generator<2>,
fn displace_y<GA>(self, displacement_generator: GA) -> Displace<2, 1, Self, GA>where
GA: Generator<2>,
Create a generator providing the results of the underlying generator after displacing the y-coordinate by the result of the provided generator.
Creates a generator which is exactly the same as the underlying generator, except the
y-coordinate of the input point is first displaced by the result of displacement_generator
for that point.
Examples
Basic usage:
let mut point = [0.2, 0.5];
let generator = Source::simplex(42) // build a generator
.displace_y(Source::simplex(43)); // apply the adapter
let value = generator.sample(point); // sample the generator
point[1] += Source::simplex(43).sample(point);
assert_eq!(value, Source::simplex(42).sample(point))