From 40ddb057973dae4663d5c77db665f90baee334b0 Mon Sep 17 00:00:00 2001 From: nsmryan Date: Sat, 29 Sep 2018 13:03:37 -0400 Subject: [PATCH] added impl-nalgebra feature --- Cargo.toml | 5 +++++ src/lib.rs | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 42cb008..956a0cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,11 @@ default = ["std", "impl-cgmath"] serialization = ["serde", "serde_derive"] std = [] impl-cgmath = ["cgmath"] +impl-nalgebra = ["nalgebra"] + +[dependencies.nalgebra] +version = "0.16" +optional = true [dependencies.cgmath] version = "0.16" diff --git a/src/lib.rs b/src/lib.rs index b2d3485..0f7b09c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,11 +98,15 @@ #[cfg(feature = "impl-cgmath")] extern crate cgmath; +#[cfg(feature = "impl-nalgebra")] extern crate nalgebra; + #[cfg(feature = "serialization")] extern crate serde; #[cfg(feature = "serialization")] #[macro_use] extern crate serde_derive; #[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::f32::consts; #[cfg(feature = "std")] use std::ops::{Add, Div, Mul, Sub}; @@ -385,6 +389,20 @@ impl Interpolate for Quaternion { } } +#[cfg(feature = "impl-nalgebra")] +impl Interpolate for Point { + fn lerp(a: Self, b: Self, t: f32) -> Self { + a.lerp(b, t) + } +} + +#[cfg(feature = "impl-nalgebra")] +impl Interpolate for Vector { + fn lerp(a: Self, b: Self, t: f32) -> Self { + a.lerp(b, t) + } +} + // Default implementation of Interpolate::cubic_hermit. pub(crate) fn cubic_hermite(x: (T, f32), a: (T, f32), b: (T, f32), y: (T, f32), t: f32) -> T where T: Copy + Add + Sub + Mul + Div {