The cubic_hermite_def function is a bit fucked as impossible to use.

This commit is contained in:
Dimitri Sabadie 2019-04-19 15:45:27 +02:00
parent 99068fb2d0
commit 427895ab10
3 changed files with 32 additions and 0 deletions

View File

@ -23,9 +23,11 @@ maintenance = { status = "actively-developed" }
default = ["std"] default = ["std"]
serialization = ["serde", "serde_derive"] serialization = ["serde", "serde_derive"]
std = ["num-traits/std"] std = ["num-traits/std"]
impl-cgmath = ["cgmath"]
impl-nalgebra = ["nalgebra"] impl-nalgebra = ["nalgebra"]
[dependencies] [dependencies]
cgmath = { version = "0.17", optional = true }
nalgebra = { version = ">=0.14, <0.19", optional = true } nalgebra = { version = ">=0.14, <0.19", optional = true }
num-traits = { version = "0.2", default-features = false } num-traits = { version = "0.2", default-features = false }
serde = { version = "1", optional = true } serde = { version = "1", optional = true }

26
src/cgmath.rs Normal file
View File

@ -0,0 +1,26 @@
use cgmath::{BaseNum, InnerSpace, Quaternion, VectorSpace, Vector2, Vector3, Vector4};
use num_traits::Float;
use crate::interpolate::{Interpolate, cubic_hermite_def};
macro_rules! impl_interpolate_vec {
($t:ty, $($q:tt)*) => {
impl Interpolate<$t> for $($q)*<$t> {
fn lerp(a: Self, b: Self, t: $t) -> Self {
a.lerp(b, t)
}
fn cubic_hermite(x: (Self, $t), a: (Self, $t), b: (Self, $t), y: (Self, $t), t: $t) -> Self {
cubic_hermite_def(x, a, b, y, t)
}
}
}
}
impl_interpolate_vec!(f32, Vector2);
//impl Interpolate for Quaternion<f32> {
// fn lerp(a: Self, b: Self, t: f32) -> Self {
// a.nlerp(b, t)
// }
//}

View File

@ -81,6 +81,9 @@
//! + This feature implements both the `Serialize` and `Deserialize` traits from `serde` for all //! + This feature implements both the `Serialize` and `Deserialize` traits from `serde` for all
//! types exported by this crate. //! types exported by this crate.
//! + Enable with the `"serialization"` feature. //! + Enable with the `"serialization"` feature.
//! - **[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.** //! - **[nalgebra](https://crates.io/crates/nalgebra) implementors.**
//! + Adds some useful implementations of `Interpolate` for some nalgebra types. //! + Adds some useful implementations of `Interpolate` for some nalgebra types.
//! + Enable with the `"impl-nalgebra"` feature. //! + Enable with the `"impl-nalgebra"` feature.
@ -94,6 +97,7 @@
#![cfg_attr(not(feature = "std"), feature(alloc))] #![cfg_attr(not(feature = "std"), feature(alloc))]
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))] #![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
#[cfg(feature = "impl-cgmath")] mod cgmath;
pub mod interpolate; pub mod interpolate;
pub mod interpolation; pub mod interpolation;
pub mod iter; pub mod iter;