pub fn lerp(&self, factor: f32) -> T {
        let len = self.0.len();

        match len {
            0 => T::default(),
            1 => self.0[0],
            _ => {
                if factor < 1.0 {
                    let factor_scaled = factor * (len - 1) as f32;
                    let start = self.0[factor_scaled as usize];
                    let end = self.0[(factor_scaled + 1.0) as usize];
                    let new_factor = factor_scaled - (factor_scaled as u32) as f32;
                    let factor_clamped = 0.0_f32.max(1.0_f32.min(new_factor));

                    ((1.0 - factor_clamped) * start.into() + factor_clamped * end.into()).into()
                } else {
                    self.0[len - 1]
                }
            }
        }
    }
/// 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);
/// ```
Linearly interpolates between the values of the curve by a factor.
Linearly interpolates between the values of the curve by a factor .
pub fn lerp(&self, factor: f32) -> T {
        let len = self.0.len();
        match len {
            0 => T::default(),
            1 => self.0[0],
            _ => {
                if factor < 1.0 {
                    let factor_scaled = factor * (len - 1) as f32;
                    let start = self.0[factor_scaled as usize];
                    let end = self.0[(factor_scaled + 1.0) as usize];
                    let new_factor = factor_scaled - (factor_scaled as u32) as f32;
                    let factor_clamped = 0.0_f32.max(1.0_f32.min(new_factor));
                    ((1.0 - factor_clamped) * start.into() + factor_clamped * end.into()).into()
                } else {
                    self.0[len - 1]
                }
            }
        }
    }
pub fn lerp ( & self , factor : f32 ) -> T { let len = self . 0 . len ( ) ; match len { 0 => T :: default ( ) , 1 => self . 0 [ 0 ] , _ => { if factor < 1.0 { let factor_scaled = factor * ( len - 1 ) as f32 ; let start = self . 0 [ factor_scaled as usize ] ; let end = self . 0 [ ( factor_scaled + 1.0 ) as usize ] ; let new_factor = factor_scaled - ( factor_scaled as u32 ) as f32 ; let factor_clamped = 0.0_f32 . max ( 1.0_f32 . min ( new_factor ) ) ; ( ( 1.0 - factor_clamped ) * start . into ( ) + factor_clamped * end . into ( ) ) . into ( ) } else { self . 0 [ len - 1 ] } } } }
Linearly interpolates between the values of the curve by a factor.
Linearly interpolates between the values of the curve by a factor .
&self
factor
f32
&self
factor
f32
examples
```
use gamemath::Curve.




` ` ` use gamemath :: Curve .