Implement impl-cgmath.

This commit is contained in:
Dimitri Sabadie
2019-04-21 18:11:06 +02:00
parent 9d5971a5f7
commit 70d6cf2081
5 changed files with 63 additions and 23 deletions

View File

@ -1,7 +1,7 @@
use splines::{Interpolation, Key, Spline};
#[cfg(feature = "impl-nalgebra")]
use nalgebra as na;
#[cfg(feature = "impl-cgmath")] use cgmath as cg;
#[cfg(feature = "impl-nalgebra")] use nalgebra as na;
#[test]
fn step_interpolation_f32() {
@ -145,6 +145,20 @@ fn several_interpolations_several_keys() {
assert_eq!(spline.clamped_sample(11.), Some(4.));
}
#[cfg(feature = "impl-cgmath")]
#[test]
fn cgmath_vector_interpolation() {
use splines::Interpolate;
let start = cg::Vector2::new(0.0, 0.0);
let mid = cg::Vector2::new(0.5, 0.5);
let end = cg::Vector2::new(1.0, 1.0);
assert_eq!(Interpolate::lerp(start, end, 0.0), start);
assert_eq!(Interpolate::lerp(start, end, 1.0), end);
assert_eq!(Interpolate::lerp(start, end, 0.5), mid);
}
#[cfg(feature = "impl-nalgebra")]
#[test]
fn nalgebra_vector_interpolation() {