matrix implementation compiles with new type variable bounds and dependance on generic_array
This commit is contained in:
parent
2912848397
commit
313f171299
@ -22,12 +22,16 @@ default = ["std", "impl-cgmath"]
|
|||||||
serialization = ["serde", "serde_derive"]
|
serialization = ["serde", "serde_derive"]
|
||||||
std = []
|
std = []
|
||||||
impl-cgmath = ["cgmath"]
|
impl-cgmath = ["cgmath"]
|
||||||
impl-nalgebra = ["nalgebra"]
|
impl-nalgebra = ["nalgebra", "generic-array"]
|
||||||
|
|
||||||
[dependencies.nalgebra]
|
[dependencies.nalgebra]
|
||||||
version = "0.14"
|
version = "0.14"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
|
[dependencies.generic-array]
|
||||||
|
version = "^0.8"
|
||||||
|
optional = true
|
||||||
|
|
||||||
[dependencies.cgmath]
|
[dependencies.cgmath]
|
||||||
version = "0.16"
|
version = "0.16"
|
||||||
optional = true
|
optional = true
|
||||||
|
14
src/lib.rs
14
src/lib.rs
@ -102,6 +102,7 @@
|
|||||||
#[cfg(feature = "impl-cgmath")] extern crate cgmath;
|
#[cfg(feature = "impl-cgmath")] extern crate cgmath;
|
||||||
|
|
||||||
#[cfg(feature = "impl-nalgebra")] extern crate nalgebra;
|
#[cfg(feature = "impl-nalgebra")] extern crate nalgebra;
|
||||||
|
#[cfg(feature = "impl-nalgebra")] extern crate generic_array;
|
||||||
|
|
||||||
#[cfg(feature = "serialization")] extern crate serde;
|
#[cfg(feature = "serialization")] extern crate serde;
|
||||||
#[cfg(feature = "serialization")] #[macro_use] extern crate serde_derive;
|
#[cfg(feature = "serialization")] #[macro_use] extern crate serde_derive;
|
||||||
@ -113,6 +114,7 @@
|
|||||||
#[cfg(feature = "impl-nalgebra")] use nalgebra::core::allocator::Allocator;
|
#[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::{DimName, DefaultAllocator, Scalar};
|
||||||
#[cfg(feature = "impl-nalgebra")] use nalgebra::storage::Storage;
|
#[cfg(feature = "impl-nalgebra")] use nalgebra::storage::Storage;
|
||||||
|
#[cfg(feature = "impl-nalgebra")] use generic_array::ArrayLength;
|
||||||
|
|
||||||
#[cfg(feature = "std")] use std::cmp::Ordering;
|
#[cfg(feature = "std")] use std::cmp::Ordering;
|
||||||
#[cfg(feature = "std")] use std::f32::consts;
|
#[cfg(feature = "std")] use std::f32::consts;
|
||||||
@ -406,22 +408,22 @@ impl<N : Scalar, D : DimName> Interpolate for na::Point<N, D>
|
|||||||
let lerp = |c1 : N, c2 : N| { Interpolate::lerp(c1, c2, t) };
|
let lerp = |c1 : N, c2 : N| { Interpolate::lerp(c1, c2, t) };
|
||||||
let coords = Matrix::zip_map(&a.coords, &b.coords, lerp);
|
let coords = Matrix::zip_map(&a.coords, &b.coords, lerp);
|
||||||
na::Point::from_coordinates(coords)
|
na::Point::from_coordinates(coords)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "impl-nalgebra")]
|
#[cfg(feature = "impl-nalgebra")]
|
||||||
impl<N, R, C> Interpolate for na::Matrix<N, R, C, <DefaultAllocator as Allocator<N, R, C>>::Buffer>
|
impl<R, C> Interpolate for na::Matrix<f32, R, C, <DefaultAllocator as Allocator<f32, R, C>>::Buffer>
|
||||||
where N : Interpolate,
|
where R : DimName,
|
||||||
N : Scalar,
|
|
||||||
R : DimName,
|
|
||||||
C : DimName,
|
C : DimName,
|
||||||
<R as na::DimName>::Value : Mul<<C as na::DimName>::Value>,
|
<R as na::DimName>::Value : Mul<<C as na::DimName>::Value>,
|
||||||
<C as na::DimName>::Value : Mul<<R as na::DimName>::Value>,
|
<C as na::DimName>::Value : Mul<<R as na::DimName>::Value>,
|
||||||
<<R as na::DimName>::Value as Mul<<C as na::DimName>::Value>>::Output : generic_array::ArrayLengh<N>
|
<<R as na::DimName>::Value as Mul<<C as na::DimName>::Value>>::Output : generic_array::ArrayLength<f32>,
|
||||||
|
<<<R as na::DimName>::Value as Mul<<C as na::DimName>::Value>>::Output as generic_array::ArrayLength<f32>>::ArrayType : Copy,
|
||||||
{
|
{
|
||||||
fn lerp(a: Self, b: Self, t: f32) -> Self
|
fn lerp(a: Self, b: Self, t: f32) -> Self
|
||||||
{
|
{
|
||||||
let lerp = |c1 : N, c2 : N| Interpolate::lerp(c1, c2, t);
|
let lerp = |c1 : f32, c2 : f32| Interpolate::lerp(c1, c2, t);
|
||||||
Matrix::zip_map(&a, &b, lerp)
|
Matrix::zip_map(&a, &b, lerp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user