Trait libnoise::Generator1D
source · pub trait Generator1D: Generator<1> {
// Provided method
fn displace_x<GA>(
self,
displacement_generator: GA
) -> Displace<1, 0, Self, GA>
where GA: Generator<1> { ... }
}Expand description
A trait representing the specialization of Generator<D> for 1-dimensional input spaces.
Anything implementing this trait must also implement Generator<1>. 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 displace_x<GA>(self, displacement_generator: GA) -> Displace<1, 0, Self, GA>where
GA: Generator<1>,
fn displace_x<GA>(self, displacement_generator: GA) -> Displace<1, 0, Self, GA>where
GA: Generator<1>,
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];
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))