Mint rebase
This commit is contained in:
parent
6b6a0717c2
commit
94db3f533b
|
@ -222,10 +222,9 @@ impl_from_into_asref_2D!(
|
|||
#[cfg(feature = "mint")]
|
||||
macro_rules! impl_from_into_mint_1D(
|
||||
($($NRows: ident => $VT:ident [$SZ: expr]);* $(;)*) => {$(
|
||||
impl<N, S> From<mint::$VT<N>> for Matrix<N, $NRows, U1, S>
|
||||
impl<N> From<mint::$VT<N>> for MatrixMN<N, $NRows, U1>
|
||||
where N: Scalar,
|
||||
S: OwnedStorage<N, $NRows, U1>,
|
||||
S::Alloc: OwnedAllocator<N, $NRows, U1, S> {
|
||||
DefaultAllocator: Allocator<N, $NRows, U1> {
|
||||
#[inline]
|
||||
fn from(v: mint::$VT<N>) -> Self {
|
||||
unsafe {
|
||||
|
@ -239,8 +238,7 @@ macro_rules! impl_from_into_mint_1D(
|
|||
|
||||
impl<N, S> Into<mint::$VT<N>> for Matrix<N, $NRows, U1, S>
|
||||
where N: Scalar,
|
||||
S: OwnedStorage<N, $NRows, U1>,
|
||||
S::Alloc: OwnedAllocator<N, $NRows, U1, S> {
|
||||
S: ContiguousStorage<N, $NRows, U1> {
|
||||
#[inline]
|
||||
fn into(self) -> mint::$VT<N> {
|
||||
unsafe {
|
||||
|
@ -254,8 +252,7 @@ macro_rules! impl_from_into_mint_1D(
|
|||
|
||||
impl<N, S> AsRef<mint::$VT<N>> for Matrix<N, $NRows, U1, S>
|
||||
where N: Scalar,
|
||||
S: OwnedStorage<N, $NRows, U1>,
|
||||
S::Alloc: OwnedAllocator<N, $NRows, U1, S> {
|
||||
S: ContiguousStorage<N, $NRows, U1> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &mint::$VT<N> {
|
||||
unsafe {
|
||||
|
@ -266,8 +263,7 @@ macro_rules! impl_from_into_mint_1D(
|
|||
|
||||
impl<N, S> AsMut<mint::$VT<N>> for Matrix<N, $NRows, U1, S>
|
||||
where N: Scalar,
|
||||
S: OwnedStorage<N, $NRows, U1>,
|
||||
S::Alloc: OwnedAllocator<N, $NRows, U1, S> {
|
||||
S: ContiguousStorageMut<N, $NRows, U1> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut mint::$VT<N> {
|
||||
unsafe {
|
||||
|
@ -289,10 +285,9 @@ impl_from_into_mint_1D!(
|
|||
#[cfg(feature = "mint")]
|
||||
macro_rules! impl_from_into_mint_2D(
|
||||
($(($NRows: ty, $NCols: ty) => $MV:ident{ $($component:ident),* }[$SZRows: expr]);* $(;)*) => {$(
|
||||
impl<N, S> From<mint::$MV<N>> for Matrix<N, $NRows, $NCols, S>
|
||||
impl<N> From<mint::$MV<N>> for MatrixMN<N, $NRows, $NCols>
|
||||
where N: Scalar,
|
||||
S: OwnedStorage<N, $NRows, $NCols>,
|
||||
S::Alloc: OwnedAllocator<N, $NRows, $NCols, S> {
|
||||
DefaultAllocator: Allocator<N, $NRows, $NCols> {
|
||||
#[inline]
|
||||
fn from(m: mint::$MV<N>) -> Self {
|
||||
unsafe {
|
||||
|
@ -308,10 +303,9 @@ macro_rules! impl_from_into_mint_2D(
|
|||
}
|
||||
}
|
||||
|
||||
impl<N, S> Into<mint::$MV<N>> for Matrix<N, $NRows, $NCols, S>
|
||||
impl<N> Into<mint::$MV<N>> for MatrixMN<N, $NRows, $NCols>
|
||||
where N: Scalar,
|
||||
S: OwnedStorage<N, $NRows, $NCols>,
|
||||
S::Alloc: OwnedAllocator<N, $NRows, $NCols, S> {
|
||||
DefaultAllocator: Allocator<N, $NRows, $NCols> {
|
||||
#[inline]
|
||||
fn into(self) -> mint::$MV<N> {
|
||||
unsafe {
|
||||
|
|
|
@ -3,10 +3,11 @@ use num::Zero;
|
|||
use alga::general::{SubsetOf, SupersetOf, Real};
|
||||
use alga::linear::Rotation as AlgaRotation;
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
use mint;
|
||||
|
||||
use core::{Vector4, Matrix4};
|
||||
use core::dimension::U3;
|
||||
#[cfg(feature = "mint")]
|
||||
use core::storage::Storage;
|
||||
use geometry::{Quaternion, UnitQuaternion, Rotation, Isometry, Similarity,
|
||||
Transform, SuperTCategoryOf, TAffine, Translation,
|
||||
Rotation3, Point3};
|
||||
|
@ -173,19 +174,14 @@ impl<N1: Real, N2: Real + SupersetOf<N1>> SubsetOf<Matrix4<N2>> for UnitQuaterni
|
|||
}
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl<N, S> From<mint::Quaternion<N>> for QuaternionBase<N, S>
|
||||
where
|
||||
N: Real,
|
||||
S: OwnedStorage<N, U4, U1>,
|
||||
S::Alloc: OwnedAllocator<N, U4, U1, S> {
|
||||
|
||||
impl<N: Real> From<mint::Quaternion<N>> for Quaternion<N> {
|
||||
fn from(q: mint::Quaternion<N>) -> Self {
|
||||
QuaternionBase::new(q.s, q.v.x, q.v.y, q.v.z)
|
||||
Quaternion::new(q.s, q.v.x, q.v.y, q.v.z)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl<N: Real, S: Storage<N, U4, U1>> Into<mint::Quaternion<N>> for QuaternionBase<N, S> {
|
||||
impl<N: Real> Into<mint::Quaternion<N>> for Quaternion<N> {
|
||||
fn into(self) -> mint::Quaternion<N> {
|
||||
mint::Quaternion {
|
||||
v: mint::Vector3 {
|
||||
|
@ -199,7 +195,7 @@ impl<N: Real, S: Storage<N, U4, U1>> Into<mint::Quaternion<N>> for QuaternionBas
|
|||
}
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl<N: Real, S: Storage<N, U4, U1>> Into<mint::Quaternion<N>> for UnitQuaternionBase<N, S> {
|
||||
impl<N: Real> Into<mint::Quaternion<N>> for UnitQuaternion<N> {
|
||||
fn into(self) -> mint::Quaternion<N> {
|
||||
mint::Quaternion {
|
||||
v: mint::Vector3 {
|
||||
|
|
|
@ -3,6 +3,9 @@ use num::Zero;
|
|||
use alga::general::{Real, SubsetOf, SupersetOf};
|
||||
use alga::linear::Rotation as AlgaRotation;
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
use mint;
|
||||
|
||||
use core::{DefaultAllocator, MatrixN};
|
||||
use core::dimension::{DimName, DimNameSum, DimNameAdd, DimMin, U1};
|
||||
use core::allocator::Allocator;
|
||||
|
@ -22,7 +25,7 @@ use geometry::{Point, Translation, Rotation, UnitQuaternion, UnitComplex, Isomet
|
|||
* Rotation -> Similarity
|
||||
* Rotation -> Transform
|
||||
* Rotation -> Matrix (homogeneous)
|
||||
* mint::EulerAngles -> RotationBase
|
||||
* mint::EulerAngles -> Rotation
|
||||
|
||||
*/
|
||||
|
||||
|
@ -205,11 +208,7 @@ impl<N1, N2, D> SubsetOf<MatrixN<N2, DimNameSum<D, U1>>> for Rotation<N1, D>
|
|||
}
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl<N, S> From<mint::EulerAngles<N, mint::IntraXYZ>> for RotationBase<N, U3, S>
|
||||
where N: Real,
|
||||
S: OwnedStorage<N, U3, U3>,
|
||||
S::Alloc: OwnedAllocator<N, U3, U3, S> {
|
||||
|
||||
impl<N: Real> From<mint::EulerAngles<N, mint::IntraXYZ>> for Rotation3<N> {
|
||||
fn from(euler: mint::EulerAngles<N, mint::IntraXYZ>) -> Self {
|
||||
Self::from_euler_angles(euler.a, euler.b, euler.c)
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ use na::{
|
|||
Matrix6x2, Matrix6x3, Matrix6x4, Matrix6x5,
|
||||
Point3, Translation3, Isometry3, Similarity3, Affine3,
|
||||
Projective3, Transform3, Rotation3, UnitQuaternion};
|
||||
#[cfg(feature = "mint")]
|
||||
use na::Quaternion;
|
||||
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
|
@ -257,74 +255,3 @@ array_matrix_conversion!(
|
|||
array_matrix_conversion_6_5, Matrix6x5, (6, 5);
|
||||
array_matrix_conversion_6_6, Matrix6, (6, 6);
|
||||
);
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
macro_rules! mint_vector_conversion(
|
||||
($($mint_vector_conversion_i: ident, $Vector: ident, $SZ: expr);* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $mint_vector_conversion_i() {
|
||||
let v = $Vector::from_fn(|i, _| i);
|
||||
let mv: mint::$Vector<usize> = v.into();
|
||||
let mv_ref: &mint::$Vector<usize> = v.as_ref();
|
||||
let v2 = $Vector::from(mv);
|
||||
let arr: [usize; $SZ] = mv.into();
|
||||
|
||||
for i in 0 .. $SZ {
|
||||
assert_eq!(arr[i], i);
|
||||
}
|
||||
|
||||
assert_eq!(&mv, mv_ref);
|
||||
assert_eq!(v, v2);
|
||||
}
|
||||
)*}
|
||||
);
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
mint_vector_conversion!(
|
||||
mint_vector_conversion_2, Vector2, 2;
|
||||
mint_vector_conversion_3, Vector3, 3;
|
||||
mint_vector_conversion_4, Vector4, 4;
|
||||
);
|
||||
|
||||
|
||||
#[test]
|
||||
fn mint_quaternion_conversions() {
|
||||
let q = Quaternion::new(0.1f64, 0.2, 0.3, 0.4);
|
||||
let mq: mint::Quaternion<f64> = q.into();
|
||||
let q2 = Quaternion::from(mq);
|
||||
|
||||
assert_eq!(mq.v.x, q[0]);
|
||||
assert_eq!(mq.v.y, q[1]);
|
||||
assert_eq!(mq.v.z, q[2]);
|
||||
assert_eq!(mq.s, q[3]);
|
||||
|
||||
assert_eq!(q, q2);
|
||||
}
|
||||
|
||||
macro_rules! mint_matrix_conversion(
|
||||
($($mint_matrix_conversion_i_j: ident, $Matrix: ident, $Mint: ident, ($NRows: expr, $NCols: expr));* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $mint_matrix_conversion_i_j() {
|
||||
let m = $Matrix::from_fn(|i, j| i * 10 + j);
|
||||
let mm: mint::$Mint<usize> = m.into();
|
||||
let m2 = $Matrix::from(mm);
|
||||
let arr: [[usize; $NRows]; $NCols] = mm.into();
|
||||
|
||||
for i in 0 .. $NRows {
|
||||
for j in 0 .. $NCols {
|
||||
assert_eq!(arr[j][i], i * 10 + j);
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(m, m2);
|
||||
}
|
||||
)*}
|
||||
);
|
||||
|
||||
mint_matrix_conversion!(
|
||||
mint_matrix_conversion_2_2, Matrix2, ColumnMatrix2, (2, 2);
|
||||
mint_matrix_conversion_3_2, Matrix3x2, ColumnMatrix3x2, (3, 2);
|
||||
mint_matrix_conversion_3_3, Matrix3, ColumnMatrix3, (3, 3);
|
||||
mint_matrix_conversion_4_3, Matrix4x3, ColumnMatrix4x3, (4, 3);
|
||||
mint_matrix_conversion_4_4, Matrix4, ColumnMatrix4, (4, 4);
|
||||
);
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
use mint;
|
||||
use na::{
|
||||
Matrix2, Matrix3, Matrix4, Matrix3x2, Matrix4x3,
|
||||
Quaternion, Vector2, Vector3, Vector4,
|
||||
};
|
||||
|
||||
macro_rules! mint_vector_conversion(
|
||||
($($mint_vector_conversion_i: ident, $Vector: ident, $SZ: expr);* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $mint_vector_conversion_i() {
|
||||
let v = $Vector::from_fn(|i, _| i);
|
||||
let mv: mint::$Vector<usize> = v.into();
|
||||
let mv_ref: &mint::$Vector<usize> = v.as_ref();
|
||||
let v2 = $Vector::from(mv);
|
||||
let arr: [usize; $SZ] = mv.into();
|
||||
|
||||
for i in 0 .. $SZ {
|
||||
assert_eq!(arr[i], i);
|
||||
}
|
||||
|
||||
assert_eq!(&mv, mv_ref);
|
||||
assert_eq!(v, v2);
|
||||
}
|
||||
)*}
|
||||
);
|
||||
|
||||
mint_vector_conversion!(
|
||||
mint_vector_conversion_2, Vector2, 2;
|
||||
mint_vector_conversion_3, Vector3, 3;
|
||||
mint_vector_conversion_4, Vector4, 4;
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn mint_quaternion_conversions() {
|
||||
let q = Quaternion::new(0.1f64, 0.2, 0.3, 0.4);
|
||||
let mq: mint::Quaternion<f64> = q.into();
|
||||
let q2 = Quaternion::from(mq);
|
||||
|
||||
assert_eq!(mq.v.x, q[0]);
|
||||
assert_eq!(mq.v.y, q[1]);
|
||||
assert_eq!(mq.v.z, q[2]);
|
||||
assert_eq!(mq.s, q[3]);
|
||||
|
||||
assert_eq!(q, q2);
|
||||
}
|
||||
|
||||
macro_rules! mint_matrix_conversion(
|
||||
($($mint_matrix_conversion_i_j: ident, $Matrix: ident, $Mint: ident, ($NRows: expr, $NCols: expr));* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $mint_matrix_conversion_i_j() {
|
||||
let m = $Matrix::from_fn(|i, j| i * 10 + j);
|
||||
let mm: mint::$Mint<usize> = m.into();
|
||||
let m2 = $Matrix::from(mm);
|
||||
let arr: [[usize; $NRows]; $NCols] = mm.into();
|
||||
|
||||
for i in 0 .. $NRows {
|
||||
for j in 0 .. $NCols {
|
||||
assert_eq!(arr[j][i], i * 10 + j);
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(m, m2);
|
||||
}
|
||||
)*}
|
||||
);
|
||||
|
||||
mint_matrix_conversion!(
|
||||
mint_matrix_conversion_2_2, Matrix2, ColumnMatrix2, (2, 2);
|
||||
mint_matrix_conversion_3_2, Matrix3x2, ColumnMatrix3x2, (3, 2);
|
||||
mint_matrix_conversion_3_3, Matrix3, ColumnMatrix3, (3, 3);
|
||||
mint_matrix_conversion_4_3, Matrix4x3, ColumnMatrix4x3, (4, 3);
|
||||
mint_matrix_conversion_4_4, Matrix4, ColumnMatrix4, (4, 4);
|
||||
);
|
|
@ -7,4 +7,4 @@ mod serde;
|
|||
#[cfg(feature = "abomonation-serialize")]
|
||||
mod abomonation;
|
||||
#[cfg(feature = "mint")]
|
||||
extern crate mint;
|
||||
mod mint;
|
||||
|
|
Loading…
Reference in New Issue