Fix compilation of tests.
This commit is contained in:
parent
50ade7e870
commit
691f58b622
|
@ -1,3 +1,6 @@
|
||||||
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
use num::Zero;
|
use num::Zero;
|
||||||
use std::ops::Neg;
|
use std::ops::Neg;
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,6 @@ test_abomonation! {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assert_encode_and_decode<T: Abomonation + PartialEq + Clone>(original_data: T) {
|
fn assert_encode_and_decode<T: Abomonation + PartialEq + Clone>(original_data: T) {
|
||||||
use std::mem::drop;
|
|
||||||
|
|
||||||
// Hold on to a clone for later comparison
|
// Hold on to a clone for later comparison
|
||||||
let data = original_data.clone();
|
let data = original_data.clone();
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use na::dimension::{U15, U8, U2, U4};
|
use na::dimension::{U15, U2, U4, U8};
|
||||||
use na::{
|
use na::{
|
||||||
self, DMatrix, DVector, Matrix2, Matrix2x3, Matrix2x4, Matrix3, Matrix3x2, Matrix3x4, Matrix4,
|
self, DMatrix, DVector, Matrix2, Matrix2x3, Matrix2x4, Matrix3, Matrix3x2, Matrix3x4, Matrix4,
|
||||||
Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RowVector3, RowVector4, RowVector5,
|
Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RowVector3, RowVector4, RowVector5, Vector1,
|
||||||
Vector1, Vector2, Vector3, Vector4, Vector5, Vector6,
|
Vector2, Vector3, Vector4, Vector5, Vector6,
|
||||||
};
|
};
|
||||||
use typenum::{UInt, UTerm};
|
|
||||||
use serde_json::error::Category::Data;
|
|
||||||
use typenum::bit::{B0, B1};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn iter() {
|
fn iter() {
|
||||||
|
@ -1025,7 +1022,9 @@ mod finite_dim_inner_space_tests {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
fn is_subspace_basis<T: FiniteDimInnerSpace<RealField = f64, ComplexField = f64> + Display>(vs: &[T]) -> bool {
|
fn is_subspace_basis<T: FiniteDimInnerSpace<RealField = f64, ComplexField = f64> + Display>(
|
||||||
|
vs: &[T],
|
||||||
|
) -> bool {
|
||||||
for i in 0..vs.len() {
|
for i in 0..vs.len() {
|
||||||
// Basis elements must be normalized.
|
// Basis elements must be normalized.
|
||||||
if !relative_eq!(vs[i].norm(), 1.0, epsilon = 1.0e-7) {
|
if !relative_eq!(vs[i].norm(), 1.0, epsilon = 1.0e-7) {
|
||||||
|
@ -1066,7 +1065,7 @@ fn partial_eq_different_types() {
|
||||||
let static_mat = Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8);
|
let static_mat = Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8);
|
||||||
|
|
||||||
let mut typenum_static_mat = MatrixMN::<u8, typenum::U1024, U4>::zeros();
|
let mut typenum_static_mat = MatrixMN::<u8, typenum::U1024, U4>::zeros();
|
||||||
let mut slice = typenum_static_mat.slice_mut((0,0), (2, 4));
|
let mut slice = typenum_static_mat.slice_mut((0, 0), (2, 4));
|
||||||
slice += static_mat;
|
slice += static_mat;
|
||||||
|
|
||||||
let fslice_of_dmat = dynamic_mat.fixed_slice::<U2, U2>(0, 0);
|
let fslice_of_dmat = dynamic_mat.fixed_slice::<U2, U2>(0, 0);
|
||||||
|
@ -1107,5 +1106,4 @@ fn partial_eq_different_types() {
|
||||||
// TODO - implement those comparisons
|
// TODO - implement those comparisons
|
||||||
// assert_ne!(static_mat, typenum_static_mat);
|
// assert_ne!(static_mat, typenum_static_mat);
|
||||||
//assert_ne!(typenum_static_mat, static_mat);
|
//assert_ne!(typenum_static_mat, static_mat);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![cfg(feature = "arbitrary")]
|
#![cfg(feature = "arbitrary")]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
|
|
||||||
use na::{Point3, Quaternion, Rotation3, Unit, UnitQuaternion, Vector3};
|
use na::{Point3, Quaternion, Rotation3, Unit, UnitQuaternion, Vector3};
|
||||||
|
|
||||||
|
@ -10,15 +11,15 @@ quickcheck!(
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
fn from_euler_angles(r: f64, p: f64, y: f64) -> bool {
|
fn from_euler_angles(r: f64, p: f64, y: f64) -> bool {
|
||||||
let roll = UnitQuaternion::from_euler_angles(r, 0.0, 0.0);
|
let roll = UnitQuaternion::from_euler_angles(r, 0.0, 0.0);
|
||||||
let pitch = UnitQuaternion::from_euler_angles(0.0, p, 0.0);
|
let pitch = UnitQuaternion::from_euler_angles(0.0, p, 0.0);
|
||||||
let yaw = UnitQuaternion::from_euler_angles(0.0, 0.0, y);
|
let yaw = UnitQuaternion::from_euler_angles(0.0, 0.0, y);
|
||||||
|
|
||||||
let rpy = UnitQuaternion::from_euler_angles(r, p, y);
|
let rpy = UnitQuaternion::from_euler_angles(r, p, y);
|
||||||
|
|
||||||
let rroll = roll.to_rotation_matrix();
|
let rroll = roll.to_rotation_matrix();
|
||||||
let rpitch = pitch.to_rotation_matrix();
|
let rpitch = pitch.to_rotation_matrix();
|
||||||
let ryaw = yaw.to_rotation_matrix();
|
let ryaw = yaw.to_rotation_matrix();
|
||||||
|
|
||||||
relative_eq!(rroll[(0, 0)], 1.0, epsilon = 1.0e-7) && // rotation wrt. x axis.
|
relative_eq!(rroll[(0, 0)], 1.0, epsilon = 1.0e-7) && // rotation wrt. x axis.
|
||||||
relative_eq!(rpitch[(1, 1)], 1.0, epsilon = 1.0e-7) && // rotation wrt. y axis.
|
relative_eq!(rpitch[(1, 1)], 1.0, epsilon = 1.0e-7) && // rotation wrt. y axis.
|
||||||
|
@ -29,22 +30,24 @@ quickcheck!(
|
||||||
fn euler_angles(r: f64, p: f64, y: f64) -> bool {
|
fn euler_angles(r: f64, p: f64, y: f64) -> bool {
|
||||||
let rpy = UnitQuaternion::from_euler_angles(r, p, y);
|
let rpy = UnitQuaternion::from_euler_angles(r, p, y);
|
||||||
let (roll, pitch, yaw) = rpy.euler_angles();
|
let (roll, pitch, yaw) = rpy.euler_angles();
|
||||||
relative_eq!(UnitQuaternion::from_euler_angles(roll, pitch, yaw), rpy, epsilon = 1.0e-7)
|
relative_eq!(
|
||||||
|
UnitQuaternion::from_euler_angles(roll, pitch, yaw),
|
||||||
|
rpy,
|
||||||
|
epsilon = 1.0e-7
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* From/to rotation matrix.
|
* From/to rotation matrix.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
fn unit_quaternion_rotation_conversion(q: UnitQuaternion<f64>) -> bool {
|
fn unit_quaternion_rotation_conversion(q: UnitQuaternion<f64>) -> bool {
|
||||||
let r = q.to_rotation_matrix();
|
let r = q.to_rotation_matrix();
|
||||||
let qq = UnitQuaternion::from_rotation_matrix(&r);
|
let qq = UnitQuaternion::from_rotation_matrix(&r);
|
||||||
let rr = qq.to_rotation_matrix();
|
let rr = qq.to_rotation_matrix();
|
||||||
|
|
||||||
relative_eq!(q, qq, epsilon = 1.0e-7) &&
|
relative_eq!(q, qq, epsilon = 1.0e-7) && relative_eq!(r, rr, epsilon = 1.0e-7)
|
||||||
relative_eq!(r, rr, epsilon = 1.0e-7)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -52,23 +55,27 @@ quickcheck!(
|
||||||
* Point/Vector transformation.
|
* Point/Vector transformation.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
fn unit_quaternion_transformation(q: UnitQuaternion<f64>, v: Vector3<f64>, p: Point3<f64>) -> bool {
|
|
||||||
|
fn unit_quaternion_transformation(
|
||||||
|
q: UnitQuaternion<f64>,
|
||||||
|
v: Vector3<f64>,
|
||||||
|
p: Point3<f64>
|
||||||
|
) -> bool
|
||||||
|
{
|
||||||
let r = q.to_rotation_matrix();
|
let r = q.to_rotation_matrix();
|
||||||
let rv = r * v;
|
let rv = r * v;
|
||||||
let rp = r * p;
|
let rp = r * p;
|
||||||
|
|
||||||
relative_eq!( q * v, rv, epsilon = 1.0e-7) &&
|
relative_eq!(q * v, rv, epsilon = 1.0e-7)
|
||||||
relative_eq!( q * &v, rv, epsilon = 1.0e-7) &&
|
&& relative_eq!(q * &v, rv, epsilon = 1.0e-7)
|
||||||
relative_eq!(&q * v, rv, epsilon = 1.0e-7) &&
|
&& relative_eq!(&q * v, rv, epsilon = 1.0e-7)
|
||||||
relative_eq!(&q * &v, rv, epsilon = 1.0e-7) &&
|
&& relative_eq!(&q * &v, rv, epsilon = 1.0e-7)
|
||||||
|
&& relative_eq!(q * p, rp, epsilon = 1.0e-7)
|
||||||
relative_eq!( q * p, rp, epsilon = 1.0e-7) &&
|
&& relative_eq!(q * &p, rp, epsilon = 1.0e-7)
|
||||||
relative_eq!( q * &p, rp, epsilon = 1.0e-7) &&
|
&& relative_eq!(&q * p, rp, epsilon = 1.0e-7)
|
||||||
relative_eq!(&q * p, rp, epsilon = 1.0e-7) &&
|
&& relative_eq!(&q * &p, rp, epsilon = 1.0e-7)
|
||||||
relative_eq!(&q * &p, rp, epsilon = 1.0e-7)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Inversion.
|
* Inversion.
|
||||||
|
@ -76,15 +83,14 @@ quickcheck!(
|
||||||
*/
|
*/
|
||||||
fn unit_quaternion_inv(q: UnitQuaternion<f64>) -> bool {
|
fn unit_quaternion_inv(q: UnitQuaternion<f64>) -> bool {
|
||||||
let iq = q.inverse();
|
let iq = q.inverse();
|
||||||
relative_eq!(&iq * &q, UnitQuaternion::identity(), epsilon = 1.0e-7) &&
|
relative_eq!(&iq * &q, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
relative_eq!( iq * &q, UnitQuaternion::identity(), epsilon = 1.0e-7) &&
|
&& relative_eq!(iq * &q, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
relative_eq!(&iq * q, UnitQuaternion::identity(), epsilon = 1.0e-7) &&
|
&& relative_eq!(&iq * q, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
relative_eq!( iq * q, UnitQuaternion::identity(), epsilon = 1.0e-7) &&
|
&& relative_eq!(iq * q, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
|
&& relative_eq!(&q * &iq, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
relative_eq!(&q * &iq, UnitQuaternion::identity(), epsilon = 1.0e-7) &&
|
&& relative_eq!(q * &iq, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
relative_eq!( q * &iq, UnitQuaternion::identity(), epsilon = 1.0e-7) &&
|
&& relative_eq!(&q * iq, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
relative_eq!(&q * iq, UnitQuaternion::identity(), epsilon = 1.0e-7) &&
|
&& relative_eq!(q * iq, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
||||||
relative_eq!( q * iq, UnitQuaternion::identity(), epsilon = 1.0e-7)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,8 +104,8 @@ quickcheck!(
|
||||||
relative_eq!(q * v, r * v, epsilon = 1.0e-7) &&
|
relative_eq!(q * v, r * v, epsilon = 1.0e-7) &&
|
||||||
relative_eq!(q * p, r * p, epsilon = 1.0e-7) &&
|
relative_eq!(q * p, r * p, epsilon = 1.0e-7) &&
|
||||||
// Equivalence q = -q
|
// Equivalence q = -q
|
||||||
relative_eq!((-q) * v, r * v, epsilon = 1.0e-7) &&
|
relative_eq!(UnitQuaternion::new_unchecked(-q.into_inner()) * v, r * v, epsilon = 1.0e-7) &&
|
||||||
relative_eq!((-q) * p, r * p, epsilon = 1.0e-7)
|
relative_eq!(UnitQuaternion::new_unchecked(-q.into_inner()) * p, r * p, epsilon = 1.0e-7)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -108,7 +114,7 @@ quickcheck!(
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
fn unit_quaternion_double_covering(q: UnitQuaternion<f64>) -> bool {
|
fn unit_quaternion_double_covering(q: UnitQuaternion<f64>) -> bool {
|
||||||
let mq = -q;
|
let mq = UnitQuaternion::new_unchecked(-q.into_inner());
|
||||||
|
|
||||||
mq == q && mq.angle() == q.angle() && mq.axis() == q.axis()
|
mq == q && mq.angle() == q.angle() && mq.axis() == q.axis()
|
||||||
}
|
}
|
||||||
|
@ -116,28 +122,34 @@ quickcheck!(
|
||||||
// Test that all operators (incl. all combinations of references) work.
|
// Test that all operators (incl. all combinations of references) work.
|
||||||
// See the top comment on `geometry/quaternion_ops.rs` for details on which operations are
|
// See the top comment on `geometry/quaternion_ops.rs` for details on which operations are
|
||||||
// supported.
|
// supported.
|
||||||
fn all_op_exist(q: Quaternion<f64>, uq: UnitQuaternion<f64>,
|
fn all_op_exist(
|
||||||
v: Vector3<f64>, p: Point3<f64>, r: Rotation3<f64>,
|
q: Quaternion<f64>,
|
||||||
s: f64) -> bool {
|
uq: UnitQuaternion<f64>,
|
||||||
|
v: Vector3<f64>,
|
||||||
|
p: Point3<f64>,
|
||||||
|
r: Rotation3<f64>,
|
||||||
|
s: f64
|
||||||
|
) -> bool
|
||||||
|
{
|
||||||
let uv = Unit::new_normalize(v);
|
let uv = Unit::new_normalize(v);
|
||||||
|
|
||||||
let qpq = q + q;
|
let qpq = q + q;
|
||||||
let qmq = q - q;
|
let qmq = q - q;
|
||||||
let qMq = q * q;
|
let qMq = q * q;
|
||||||
let mq = -q;
|
let mq = -q;
|
||||||
let qMs = q * s;
|
let qMs = q * s;
|
||||||
let qDs = q / s;
|
let qDs = q / s;
|
||||||
let sMq = s * q;
|
let sMq = s * q;
|
||||||
|
|
||||||
let uqMuq = uq * uq;
|
let uqMuq = uq * uq;
|
||||||
let uqMr = uq * r;
|
let uqMr = uq * r;
|
||||||
let rMuq = r * uq;
|
let rMuq = r * uq;
|
||||||
let uqDuq = uq / uq;
|
let uqDuq = uq / uq;
|
||||||
let uqDr = uq / r;
|
let uqDr = uq / r;
|
||||||
let rDuq = r / uq;
|
let rDuq = r / uq;
|
||||||
|
|
||||||
let uqMp = uq * p;
|
let uqMp = uq * p;
|
||||||
let uqMv = uq * v;
|
let uqMv = uq * v;
|
||||||
let uqMuv = uq * uv;
|
let uqMuv = uq * uv;
|
||||||
|
|
||||||
let mut qMs1 = q;
|
let mut qMs1 = q;
|
||||||
|
@ -186,81 +198,60 @@ quickcheck!(
|
||||||
uqDr1 /= r;
|
uqDr1 /= r;
|
||||||
uqDr2 /= &r;
|
uqDr2 /= &r;
|
||||||
|
|
||||||
qMs1 == qMs &&
|
qMs1 == qMs
|
||||||
|
&& qMq1 == qMq
|
||||||
qMq1 == qMq &&
|
&& qMq1 == qMq2
|
||||||
qMq1 == qMq2 &&
|
&& qpq1 == qpq
|
||||||
|
&& qpq1 == qpq2
|
||||||
qpq1 == qpq &&
|
&& qmq1 == qmq
|
||||||
qpq1 == qpq2 &&
|
&& qmq1 == qmq2
|
||||||
|
&& uqMuq1 == uqMuq
|
||||||
qmq1 == qmq &&
|
&& uqMuq1 == uqMuq2
|
||||||
qmq1 == qmq2 &&
|
&& uqMr1 == uqMr
|
||||||
|
&& uqMr1 == uqMr2
|
||||||
uqMuq1 == uqMuq &&
|
&& uqDuq1 == uqDuq
|
||||||
uqMuq1 == uqMuq2 &&
|
&& uqDuq1 == uqDuq2
|
||||||
|
&& uqDr1 == uqDr
|
||||||
uqMr1 == uqMr &&
|
&& uqDr1 == uqDr2
|
||||||
uqMr1 == uqMr2 &&
|
&& qpq == &q + &q
|
||||||
|
&& qpq == q + &q
|
||||||
uqDuq1 == uqDuq &&
|
&& qpq == &q + q
|
||||||
uqDuq1 == uqDuq2 &&
|
&& qmq == &q - &q
|
||||||
|
&& qmq == q - &q
|
||||||
uqDr1 == uqDr &&
|
&& qmq == &q - q
|
||||||
uqDr1 == uqDr2 &&
|
&& qMq == &q * &q
|
||||||
|
&& qMq == q * &q
|
||||||
qpq == &q + &q &&
|
&& qMq == &q * q
|
||||||
qpq == q + &q &&
|
&& mq == -&q
|
||||||
qpq == &q + q &&
|
&& qMs == &q * s
|
||||||
|
&& qDs == &q / s
|
||||||
qmq == &q - &q &&
|
&& sMq == s * &q
|
||||||
qmq == q - &q &&
|
&& uqMuq == &uq * &uq
|
||||||
qmq == &q - q &&
|
&& uqMuq == uq * &uq
|
||||||
|
&& uqMuq == &uq * uq
|
||||||
qMq == &q * &q &&
|
&& uqMr == &uq * &r
|
||||||
qMq == q * &q &&
|
&& uqMr == uq * &r
|
||||||
qMq == &q * q &&
|
&& uqMr == &uq * r
|
||||||
|
&& rMuq == &r * &uq
|
||||||
mq == -&q &&
|
&& rMuq == r * &uq
|
||||||
|
&& rMuq == &r * uq
|
||||||
qMs == &q * s &&
|
&& uqDuq == &uq / &uq
|
||||||
qDs == &q / s &&
|
&& uqDuq == uq / &uq
|
||||||
sMq == s * &q &&
|
&& uqDuq == &uq / uq
|
||||||
|
&& uqDr == &uq / &r
|
||||||
uqMuq == &uq * &uq &&
|
&& uqDr == uq / &r
|
||||||
uqMuq == uq * &uq &&
|
&& uqDr == &uq / r
|
||||||
uqMuq == &uq * uq &&
|
&& rDuq == &r / &uq
|
||||||
|
&& rDuq == r / &uq
|
||||||
uqMr == &uq * &r &&
|
&& rDuq == &r / uq
|
||||||
uqMr == uq * &r &&
|
&& uqMp == &uq * &p
|
||||||
uqMr == &uq * r &&
|
&& uqMp == uq * &p
|
||||||
|
&& uqMp == &uq * p
|
||||||
rMuq == &r * &uq &&
|
&& uqMv == &uq * &v
|
||||||
rMuq == r * &uq &&
|
&& uqMv == uq * &v
|
||||||
rMuq == &r * uq &&
|
&& uqMv == &uq * v
|
||||||
|
&& uqMuv == &uq * &uv
|
||||||
uqDuq == &uq / &uq &&
|
&& uqMuv == uq * &uv
|
||||||
uqDuq == uq / &uq &&
|
&& uqMuv == &uq * uv
|
||||||
uqDuq == &uq / uq &&
|
|
||||||
|
|
||||||
uqDr == &uq / &r &&
|
|
||||||
uqDr == uq / &r &&
|
|
||||||
uqDr == &uq / r &&
|
|
||||||
|
|
||||||
rDuq == &r / &uq &&
|
|
||||||
rDuq == r / &uq &&
|
|
||||||
rDuq == &r / uq &&
|
|
||||||
|
|
||||||
uqMp == &uq * &p &&
|
|
||||||
uqMp == uq * &p &&
|
|
||||||
uqMp == &uq * p &&
|
|
||||||
|
|
||||||
uqMv == &uq * &v &&
|
|
||||||
uqMv == uq * &v &&
|
|
||||||
uqMv == &uq * v &&
|
|
||||||
|
|
||||||
uqMuv == &uq * &uv &&
|
|
||||||
uqMuv == uq * &uv &&
|
|
||||||
uqMuv == &uq * uv
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue