added impl-nalgebra feature

This commit is contained in:
nsmryan 2018-09-29 13:03:37 -04:00
parent 3cd65dce54
commit 40ddb05797
2 changed files with 23 additions and 0 deletions

View File

@ -22,6 +22,11 @@ default = ["std", "impl-cgmath"]
serialization = ["serde", "serde_derive"] serialization = ["serde", "serde_derive"]
std = [] std = []
impl-cgmath = ["cgmath"] impl-cgmath = ["cgmath"]
impl-nalgebra = ["nalgebra"]
[dependencies.nalgebra]
version = "0.16"
optional = true
[dependencies.cgmath] [dependencies.cgmath]
version = "0.16" version = "0.16"

View File

@ -98,11 +98,15 @@
#[cfg(feature = "impl-cgmath")] extern crate cgmath; #[cfg(feature = "impl-cgmath")] extern crate cgmath;
#[cfg(feature = "impl-nalgebra")] extern crate nalgebra;
#[cfg(feature = "serialization")] extern crate serde; #[cfg(feature = "serialization")] extern crate serde;
#[cfg(feature = "serialization")] #[macro_use] extern crate serde_derive; #[cfg(feature = "serialization")] #[macro_use] extern crate serde_derive;
#[cfg(feature = "impl-cgmath")] use cgmath::{InnerSpace, Quaternion, Vector2, Vector3, Vector4}; #[cfg(feature = "impl-cgmath")] use cgmath::{InnerSpace, Quaternion, Vector2, Vector3, Vector4};
#[cfg(feature = "impl-nalgera")] use nalgera::{Point, Vector};
#[cfg(feature = "std")] use std::cmp::Ordering; #[cfg(feature = "std")] use std::cmp::Ordering;
#[cfg(feature = "std")] use std::f32::consts; #[cfg(feature = "std")] use std::f32::consts;
#[cfg(feature = "std")] use std::ops::{Add, Div, Mul, Sub}; #[cfg(feature = "std")] use std::ops::{Add, Div, Mul, Sub};
@ -385,6 +389,20 @@ impl Interpolate for Quaternion<f32> {
} }
} }
#[cfg(feature = "impl-nalgebra")]
impl<T : Interpolate > Interpolate for Point<T> {
fn lerp(a: Self, b: Self, t: f32) -> Self {
a.lerp(b, t)
}
}
#[cfg(feature = "impl-nalgebra")]
impl<T : Interpolate > Interpolate for Vector<T> {
fn lerp(a: Self, b: Self, t: f32) -> Self {
a.lerp(b, t)
}
}
// Default implementation of Interpolate::cubic_hermit. // Default implementation of Interpolate::cubic_hermit.
pub(crate) fn cubic_hermite<T>(x: (T, f32), a: (T, f32), b: (T, f32), y: (T, f32), t: f32) -> T pub(crate) fn cubic_hermite<T>(x: (T, f32), a: (T, f32), b: (T, f32), y: (T, f32), t: f32) -> T
where T: Copy + Add<Output = T> + Sub<Output = T> + Mul<f32, Output = T> + Div<f32, Output = T> { where T: Copy + Add<Output = T> + Sub<Output = T> + Mul<f32, Output = T> + Div<f32, Output = T> {