0.2.3.
This commit is contained in:
		
							
								
								
									
										11
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -1,3 +1,11 @@ | ||||
| ## 0.2.3 | ||||
|  | ||||
| > Sat 13th October 2018 | ||||
|  | ||||
|   - Add the `"impl-nalgebra"` feature gate. It gives access to some implementors for the `nalgebra` | ||||
|     crate. | ||||
|   - Enhance the documentation. | ||||
|  | ||||
| ## 0.2.2 | ||||
|  | ||||
| > Sun 30th September 2018 | ||||
| @@ -16,7 +24,8 @@ | ||||
| > Thu 6th September 2018 | ||||
|  | ||||
|   - Add the `"std"` feature gate, that can be used to compile with the standard library. | ||||
|   - Add the `"impl-cgmath"` in order to make it optional, if wanted, the `cgmath` dependency. | ||||
|   - Add the `"impl-cgmath"` feature gate in order to make optional, if wanted, the `cgmath` | ||||
|     dependency. | ||||
|   - Enhance the documentation. | ||||
|  | ||||
| ## 0.1.1 | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| [package] | ||||
| name = "splines" | ||||
| version = "0.2.2" | ||||
| version = "0.2.3" | ||||
| license = "BSD-3-Clause" | ||||
| authors = ["Dimitri Sabadie <dimitri.sabadie@gmail.com>"] | ||||
| description = "Spline interpolation made easy" | ||||
|   | ||||
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @@ -10,11 +10,15 @@ Feel free to dig in the [online documentation](https://docs.rs/splines) for furt | ||||
| This crate has features! Here’s a comprehensive list of what you can enable: | ||||
|  | ||||
|   - **Serialization / deserialization.** | ||||
|     + This feature implements both the `Serialize` and `Deserialize` traits from `serde`. | ||||
|     + This feature implements both the `Serialize` and `Deserialize` traits from `serde` for all | ||||
|       types exported by this crate. | ||||
|     + Enable with the `"serialization"` feature. | ||||
|   - **[cgmath](https://crates.io/crates/cgmath) implementors** | ||||
|     + Adds some usefull implementations of `Interpolate` for some cgmath types. | ||||
|   - **[cgmath](https://crates.io/crates/cgmath) implementors.** | ||||
|     + Adds some useful implementations of `Interpolate` for some cgmath types. | ||||
|     + Enable with the `"impl-cgmath"` feature. | ||||
|   - **[nalgebra](https://crates.io/crates/nalgebra) implementors.** | ||||
|     + Adds some useful implementations of `Interpolate` for some nalgebra types. | ||||
|     + Enable with the `"impl-nalgebra"` feature. | ||||
|   - **Standard library / no standard library.** | ||||
|     + It’s possible to compile against the standard library or go on your own without it. | ||||
|     + Compiling with the standard library is enabled by default. | ||||
|   | ||||
| @@ -81,10 +81,10 @@ | ||||
| //!       types exported by this crate. | ||||
| //!     + Enable with the `"serialization"` feature. | ||||
| //!   - **[cgmath](https://crates.io/crates/cgmath) implementors.** | ||||
| //!     + Adds some usefull implementations of `Interpolate` for some cgmath types. | ||||
| //!     + Adds some useful implementations of `Interpolate` for some cgmath types. | ||||
| //!     + Enable with the `"impl-cgmath"` feature. | ||||
| //!   - **[nalgebra](https://crates.io/crates/nalgebra) implementors.** | ||||
| //!     + Adds some usefull implementations of `Interpolate` for some nalgebra types. | ||||
| //!     + Adds some useful implementations of `Interpolate` for some nalgebra types. | ||||
| //!     + Enable with the `"impl-nalgebra"` feature. | ||||
| //!   - **Standard library / no standard library.** | ||||
| //!     + It’s possible to compile against the standard library or go on your own without it. | ||||
| @@ -109,8 +109,8 @@ | ||||
| #[cfg(feature = "impl-cgmath")] use cgmath::{InnerSpace, Quaternion, Vector2, Vector3, Vector4}; | ||||
|  | ||||
| #[cfg(feature = "impl-nalgebra")] use nalgebra as na; | ||||
| #[cfg(feature = "impl-nalgebra")] use nalgebra::core::allocator::Allocator; | ||||
| #[cfg(feature = "impl-nalgebra")] use nalgebra::core::{DimName, DefaultAllocator, Scalar}; | ||||
| #[cfg(feature = "impl-nalgebra")] use nalgebra::core::allocator::Allocator; | ||||
|  | ||||
| #[cfg(feature = "std")] use std::cmp::Ordering; | ||||
| #[cfg(feature = "std")] use std::f32::consts; | ||||
|   | ||||
							
								
								
									
										64
									
								
								tests/mod.rs
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								tests/mod.rs
									
									
									
									
									
								
							| @@ -8,8 +8,8 @@ use splines::{Interpolation, Key, Spline}; | ||||
|  | ||||
| #[test] | ||||
| fn step_interpolation_0() { | ||||
|   let start  = Key::new(0., 0., Interpolation::Step(0.)); | ||||
|   let end    = Key::new(1., 10., Interpolation::default()); | ||||
|   let start = Key::new(0., 0., Interpolation::Step(0.)); | ||||
|   let end = Key::new(1., 10., Interpolation::default()); | ||||
|   let spline = Spline::from_vec(vec![start, end]); | ||||
|  | ||||
|   assert_eq!(spline.sample(0.), Some(10.)); | ||||
| @@ -23,8 +23,8 @@ fn step_interpolation_0() { | ||||
|  | ||||
| #[test] | ||||
| fn step_interpolation_0_5() { | ||||
|   let start  = Key::new(0., 0., Interpolation::Step(0.5)); | ||||
|   let end    = Key::new(1., 10., Interpolation::default()); | ||||
|   let start = Key::new(0., 0., Interpolation::Step(0.5)); | ||||
|   let end = Key::new(1., 10., Interpolation::default()); | ||||
|   let spline = Spline::from_vec(vec![start, end]); | ||||
|  | ||||
|   assert_eq!(spline.sample(0.), Some(0.)); | ||||
| @@ -38,8 +38,8 @@ fn step_interpolation_0_5() { | ||||
|  | ||||
| #[test] | ||||
| fn step_interpolation_0_75() { | ||||
|   let start  = Key::new(0., 0., Interpolation::Step(0.75)); | ||||
|   let end    = Key::new(1., 10., Interpolation::default()); | ||||
|   let start = Key::new(0., 0., Interpolation::Step(0.75)); | ||||
|   let end = Key::new(1., 10., Interpolation::default()); | ||||
|   let spline = Spline::from_vec(vec![start, end]); | ||||
|  | ||||
|   assert_eq!(spline.sample(0.), Some(0.)); | ||||
| @@ -53,8 +53,8 @@ fn step_interpolation_0_75() { | ||||
|  | ||||
| #[test] | ||||
| fn step_interpolation_1() { | ||||
|   let start  = Key::new(0., 0., Interpolation::Step(1.)); | ||||
|   let end    = Key::new(1., 10., Interpolation::default()); | ||||
|   let start = Key::new(0., 0., Interpolation::Step(1.)); | ||||
|   let end = Key::new(1., 10., Interpolation::default()); | ||||
|   let spline = Spline::from_vec(vec![start, end]); | ||||
|  | ||||
|   assert_eq!(spline.sample(0.), Some(0.)); | ||||
| @@ -68,8 +68,8 @@ fn step_interpolation_1() { | ||||
|  | ||||
| #[test] | ||||
| fn linear_interpolation() { | ||||
|   let start  = Key::new(0., 0., Interpolation::Linear); | ||||
|   let end    = Key::new(1., 10., Interpolation::default()); | ||||
|   let start = Key::new(0., 0., Interpolation::Linear); | ||||
|   let end = Key::new(1., 10., Interpolation::default()); | ||||
|   let spline = Spline::from_vec(vec![start, end]); | ||||
|  | ||||
|   assert_eq!(spline.sample(0.), Some(0.)); | ||||
| @@ -84,11 +84,11 @@ fn linear_interpolation() { | ||||
| #[test] | ||||
| fn linear_interpolation_several_keys() { | ||||
|   let start = Key::new(0., 0., Interpolation::Linear); | ||||
|   let k1    = Key::new(1., 5., Interpolation::Linear); | ||||
|   let k2    = Key::new(2., 0., Interpolation::Linear); | ||||
|   let k3    = Key::new(3., 1., Interpolation::Linear); | ||||
|   let k4    = Key::new(10., 2., Interpolation::Linear); | ||||
|   let end   = Key::new(11., 4., Interpolation::default()); | ||||
|   let k1 = Key::new(1., 5., Interpolation::Linear); | ||||
|   let k2 = Key::new(2., 0., Interpolation::Linear); | ||||
|   let k3 = Key::new(3., 1., Interpolation::Linear); | ||||
|   let k4 = Key::new(10., 2., Interpolation::Linear); | ||||
|   let end = Key::new(11., 4., Interpolation::default()); | ||||
|   let spline = Spline::from_vec(vec![start, k1, k2, k3, k4, end]); | ||||
|  | ||||
|   assert_eq!(spline.sample(0.), Some(0.)); | ||||
| @@ -109,11 +109,11 @@ fn linear_interpolation_several_keys() { | ||||
| #[test] | ||||
| fn several_interpolations_several_keys() { | ||||
|   let start = Key::new(0., 0., Interpolation::Step(0.5)); | ||||
|   let k1    = Key::new(1., 5., Interpolation::Linear); | ||||
|   let k2    = Key::new(2., 0., Interpolation::Step(0.1)); | ||||
|   let k3    = Key::new(3., 1., Interpolation::Linear); | ||||
|   let k4    = Key::new(10., 2., Interpolation::Linear); | ||||
|   let end   = Key::new(11., 4., Interpolation::default()); | ||||
|   let k1 = Key::new(1., 5., Interpolation::Linear); | ||||
|   let k2 = Key::new(2., 0., Interpolation::Step(0.1)); | ||||
|   let k3 = Key::new(3., 1., Interpolation::Linear); | ||||
|   let k4 = Key::new(10., 2., Interpolation::Linear); | ||||
|   let end = Key::new(11., 4., Interpolation::default()); | ||||
|   let spline = Spline::from_vec(vec![start, k1, k2, k3, k4, end]); | ||||
|  | ||||
|   assert_eq!(spline.sample(0.), Some(0.)); | ||||
| @@ -136,24 +136,24 @@ fn several_interpolations_several_keys() { | ||||
| #[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); | ||||
|   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); | ||||
|   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); | ||||
|   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); | ||||
|   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