Struct gamemath::Curve [−][src]
pub struct Curve<T>(_);
A heap allocated structure for representing a value curve.
Methods
impl<T> Curve<T> where
T: Default + Clone + Copy + From<f32> + Into<f32>,
[src]
impl<T> Curve<T> where
T: Default + Clone + Copy + From<f32> + Into<f32>,
pub fn new(values: &[T]) -> Curve<T>
[src]
pub fn new(values: &[T]) -> Curve<T>
Constructs a Curve
from a slice of values.
Examples
use gamemath::Curve; let c: Curve<f32> = Curve::new(&[0.0, 10.0, 5.0, 0.0]); assert_eq!(c[0], 0.0); assert_eq!(c[1], 10.0); assert_eq!(c[2], 5.0); assert_eq!(c[3], 0.0);
pub fn lerp(&self, factor: f32) -> T
[src]
pub fn lerp(&self, factor: f32) -> T
Linearly interpolates between the values of the curve by a factor.
Examples
use gamemath::Curve; let c: Curve<f32> = Curve::new(&[0.0, 10.0, 5.0, 0.0]); assert_eq!(c.lerp(0.75), 3.75);
Trait Implementations
impl<T> Index<usize> for Curve<T>
[src]
impl<T> Index<usize> for Curve<T>
type Output = T
The returned type after indexing.
fn index(&self, index: usize) -> &T
[src]
fn index(&self, index: usize) -> &T
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<usize> for Curve<T>
[src]
impl<T> IndexMut<usize> for Curve<T>