Add support for nalgebra along with some tests.
Feature-gated with impl-nalgebra.
This commit is contained in:
29
tests/mod.rs
29
tests/mod.rs
@ -1,4 +1,8 @@
|
||||
extern crate splines;
|
||||
#[cfg(feature = "impl-nalgebra")] extern crate nalgebra;
|
||||
|
||||
#[cfg(feature = "impl-nalgebra")] use nalgebra as na;
|
||||
#[cfg(feature = "impl-nalgebra")] use splines::Interpolate;
|
||||
|
||||
use splines::{Interpolation, Key, Spline};
|
||||
|
||||
@ -128,3 +132,28 @@ fn several_interpolations_several_keys() {
|
||||
assert_eq!(spline.sample(10.), Some(2.));
|
||||
assert_eq!(spline.clamped_sample(11.), 4.);
|
||||
}
|
||||
|
||||
#[cfg(feature = "impl-nalgebra")]
|
||||
#[test]
|
||||
fn nalgebra_point_interpolation() {
|
||||
let start = na::Point2::new(0.0, 0.0);
|
||||
let mid = na::Point2::new(0.5, 0.5);
|
||||
let end = na::Point2::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() {
|
||||
let start = na::Vector2::new(0.0, 0.0);
|
||||
let mid = na::Vector2::new(0.5, 0.5);
|
||||
let end = na::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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user