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 std::ops::Neg;
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ test_abomonation! {
|
|||
}
|
||||
|
||||
fn assert_encode_and_decode<T: Abomonation + PartialEq + Clone>(original_data: T) {
|
||||
use std::mem::drop;
|
||||
|
||||
// Hold on to a clone for later comparison
|
||||
let data = original_data.clone();
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
use num::{One, Zero};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use na::dimension::{U15, U8, U2, U4};
|
||||
use na::dimension::{U15, U2, U4, U8};
|
||||
use na::{
|
||||
self, DMatrix, DVector, Matrix2, Matrix2x3, Matrix2x4, Matrix3, Matrix3x2, Matrix3x4, Matrix4,
|
||||
Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RowVector3, RowVector4, RowVector5,
|
||||
Vector1, Vector2, Vector3, Vector4, Vector5, Vector6,
|
||||
Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RowVector3, RowVector4, RowVector5, Vector1,
|
||||
Vector2, Vector3, Vector4, Vector5, Vector6,
|
||||
};
|
||||
use typenum::{UInt, UTerm};
|
||||
use serde_json::error::Category::Data;
|
||||
use typenum::bit::{B0, B1};
|
||||
|
||||
#[test]
|
||||
fn iter() {
|
||||
|
@ -1025,7 +1022,9 @@ mod finite_dim_inner_space_tests {
|
|||
*
|
||||
*/
|
||||
#[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() {
|
||||
// Basis elements must be normalized.
|
||||
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 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;
|
||||
|
||||
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
|
||||
// assert_ne!(static_mat, typenum_static_mat);
|
||||
//assert_ne!(typenum_static_mat, static_mat);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![cfg(feature = "arbitrary")]
|
||||
#![allow(non_snake_case)]
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
|
||||
use na::{Point3, Quaternion, Rotation3, Unit, UnitQuaternion, Vector3};
|
||||
|
||||
|
@ -10,15 +11,15 @@ quickcheck!(
|
|||
*
|
||||
*/
|
||||
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 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 rroll = roll.to_rotation_matrix();
|
||||
let rroll = roll.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!(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 {
|
||||
let rpy = UnitQuaternion::from_euler_angles(r, p, y);
|
||||
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.
|
||||
*
|
||||
*/
|
||||
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 rr = qq.to_rotation_matrix();
|
||||
|
||||
relative_eq!(q, qq, epsilon = 1.0e-7) &&
|
||||
relative_eq!(r, rr, epsilon = 1.0e-7)
|
||||
relative_eq!(q, qq, epsilon = 1.0e-7) && relative_eq!(r, rr, epsilon = 1.0e-7)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -52,23 +55,27 @@ quickcheck!(
|
|||
* 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 rv = r * v;
|
||||
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 * 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 * 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)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Inversion.
|
||||
|
@ -76,15 +83,14 @@ quickcheck!(
|
|||
*/
|
||||
fn unit_quaternion_inv(q: UnitQuaternion<f64>) -> bool {
|
||||
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!(&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!(&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)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -98,8 +104,8 @@ quickcheck!(
|
|||
relative_eq!(q * v, r * v, epsilon = 1.0e-7) &&
|
||||
relative_eq!(q * p, r * p, epsilon = 1.0e-7) &&
|
||||
// Equivalence q = -q
|
||||
relative_eq!((-q) * 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()) * v, r * v, 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 {
|
||||
let mq = -q;
|
||||
let mq = UnitQuaternion::new_unchecked(-q.into_inner());
|
||||
|
||||
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.
|
||||
// See the top comment on `geometry/quaternion_ops.rs` for details on which operations are
|
||||
// supported.
|
||||
fn all_op_exist(q: Quaternion<f64>, uq: UnitQuaternion<f64>,
|
||||
v: Vector3<f64>, p: Point3<f64>, r: Rotation3<f64>,
|
||||
s: f64) -> bool {
|
||||
fn all_op_exist(
|
||||
q: Quaternion<f64>,
|
||||
uq: UnitQuaternion<f64>,
|
||||
v: Vector3<f64>,
|
||||
p: Point3<f64>,
|
||||
r: Rotation3<f64>,
|
||||
s: f64
|
||||
) -> bool
|
||||
{
|
||||
let uv = Unit::new_normalize(v);
|
||||
|
||||
let qpq = q + q;
|
||||
let qmq = q - q;
|
||||
let qMq = q * q;
|
||||
let mq = -q;
|
||||
let mq = -q;
|
||||
let qMs = q * s;
|
||||
let qDs = q / s;
|
||||
let sMq = s * q;
|
||||
|
||||
let uqMuq = uq * uq;
|
||||
let uqMr = uq * r;
|
||||
let rMuq = r * uq;
|
||||
let uqMr = uq * r;
|
||||
let rMuq = r * uq;
|
||||
let uqDuq = uq / uq;
|
||||
let uqDr = uq / r;
|
||||
let rDuq = r / uq;
|
||||
let uqDr = uq / r;
|
||||
let rDuq = r / uq;
|
||||
|
||||
let uqMp = uq * p;
|
||||
let uqMv = uq * v;
|
||||
let uqMp = uq * p;
|
||||
let uqMv = uq * v;
|
||||
let uqMuv = uq * uv;
|
||||
|
||||
let mut qMs1 = q;
|
||||
|
@ -186,81 +198,60 @@ quickcheck!(
|
|||
uqDr1 /= r;
|
||||
uqDr2 /= &r;
|
||||
|
||||
qMs1 == qMs &&
|
||||
|
||||
qMq1 == qMq &&
|
||||
qMq1 == qMq2 &&
|
||||
|
||||
qpq1 == qpq &&
|
||||
qpq1 == qpq2 &&
|
||||
|
||||
qmq1 == qmq &&
|
||||
qmq1 == qmq2 &&
|
||||
|
||||
uqMuq1 == uqMuq &&
|
||||
uqMuq1 == uqMuq2 &&
|
||||
|
||||
uqMr1 == uqMr &&
|
||||
uqMr1 == uqMr2 &&
|
||||
|
||||
uqDuq1 == uqDuq &&
|
||||
uqDuq1 == uqDuq2 &&
|
||||
|
||||
uqDr1 == uqDr &&
|
||||
uqDr1 == uqDr2 &&
|
||||
|
||||
qpq == &q + &q &&
|
||||
qpq == q + &q &&
|
||||
qpq == &q + q &&
|
||||
|
||||
qmq == &q - &q &&
|
||||
qmq == q - &q &&
|
||||
qmq == &q - q &&
|
||||
|
||||
qMq == &q * &q &&
|
||||
qMq == q * &q &&
|
||||
qMq == &q * q &&
|
||||
|
||||
mq == -&q &&
|
||||
|
||||
qMs == &q * s &&
|
||||
qDs == &q / s &&
|
||||
sMq == s * &q &&
|
||||
|
||||
uqMuq == &uq * &uq &&
|
||||
uqMuq == uq * &uq &&
|
||||
uqMuq == &uq * uq &&
|
||||
|
||||
uqMr == &uq * &r &&
|
||||
uqMr == uq * &r &&
|
||||
uqMr == &uq * r &&
|
||||
|
||||
rMuq == &r * &uq &&
|
||||
rMuq == r * &uq &&
|
||||
rMuq == &r * uq &&
|
||||
|
||||
uqDuq == &uq / &uq &&
|
||||
uqDuq == uq / &uq &&
|
||||
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
|
||||
qMs1 == qMs
|
||||
&& qMq1 == qMq
|
||||
&& qMq1 == qMq2
|
||||
&& qpq1 == qpq
|
||||
&& qpq1 == qpq2
|
||||
&& qmq1 == qmq
|
||||
&& qmq1 == qmq2
|
||||
&& uqMuq1 == uqMuq
|
||||
&& uqMuq1 == uqMuq2
|
||||
&& uqMr1 == uqMr
|
||||
&& uqMr1 == uqMr2
|
||||
&& uqDuq1 == uqDuq
|
||||
&& uqDuq1 == uqDuq2
|
||||
&& uqDr1 == uqDr
|
||||
&& uqDr1 == uqDr2
|
||||
&& qpq == &q + &q
|
||||
&& qpq == q + &q
|
||||
&& qpq == &q + q
|
||||
&& qmq == &q - &q
|
||||
&& qmq == q - &q
|
||||
&& qmq == &q - q
|
||||
&& qMq == &q * &q
|
||||
&& qMq == q * &q
|
||||
&& qMq == &q * q
|
||||
&& mq == -&q
|
||||
&& qMs == &q * s
|
||||
&& qDs == &q / s
|
||||
&& sMq == s * &q
|
||||
&& uqMuq == &uq * &uq
|
||||
&& uqMuq == uq * &uq
|
||||
&& uqMuq == &uq * uq
|
||||
&& uqMr == &uq * &r
|
||||
&& uqMr == uq * &r
|
||||
&& uqMr == &uq * r
|
||||
&& rMuq == &r * &uq
|
||||
&& rMuq == r * &uq
|
||||
&& rMuq == &r * uq
|
||||
&& uqDuq == &uq / &uq
|
||||
&& uqDuq == uq / &uq
|
||||
&& 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