2013-05-19 01:04:03 +08:00
|
|
|
#[test]
|
2013-05-19 19:53:19 +08:00
|
|
|
use core::num::{One, abs};
|
2013-05-19 01:04:03 +08:00
|
|
|
#[test]
|
|
|
|
use core::rand::{random};
|
|
|
|
#[test]
|
2013-05-21 23:25:01 +08:00
|
|
|
use core::cmp::ApproxEq;
|
2013-05-19 01:04:03 +08:00
|
|
|
#[test]
|
2013-05-19 05:56:03 +08:00
|
|
|
use traits::inv::Inv;
|
|
|
|
#[test]
|
2013-05-19 19:53:19 +08:00
|
|
|
use traits::rotation::Rotation;
|
|
|
|
#[test]
|
|
|
|
use dim1::vec1::vec1;
|
|
|
|
#[test]
|
2013-05-19 01:04:03 +08:00
|
|
|
use dim1::mat1::Mat1;
|
|
|
|
#[test]
|
|
|
|
use dim2::mat2::Mat2;
|
|
|
|
#[test]
|
|
|
|
use dim3::mat3::Mat3;
|
2013-05-19 19:53:19 +08:00
|
|
|
#[test]
|
|
|
|
use adaptors::rotmat::Rotmat;
|
2013-05-19 01:04:03 +08:00
|
|
|
|
|
|
|
// FIXME: this one fails with an ICE: node_id_to_type: no type for node [...]
|
|
|
|
// #[test]
|
|
|
|
// fn test_inv_nmat()
|
|
|
|
// {
|
|
|
|
// let randmat : NMat<d7, f64> = random();
|
|
|
|
//
|
2013-05-21 23:25:01 +08:00
|
|
|
// assert!((randmat.inverse() * randmat).approx_eq(&One::one()));
|
2013-05-19 01:04:03 +08:00
|
|
|
// }
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_inv_mat1()
|
|
|
|
{
|
|
|
|
for uint::range(0u, 10000u) |_|
|
|
|
|
{
|
|
|
|
let randmat : Mat1<f64> = random();
|
|
|
|
|
2013-05-21 23:25:01 +08:00
|
|
|
assert!((randmat.inverse() * randmat).approx_eq(&One::one()));
|
2013-05-19 01:04:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_inv_mat2()
|
|
|
|
{
|
|
|
|
for uint::range(0u, 10000u) |_|
|
|
|
|
{
|
|
|
|
let randmat : Mat2<f64> = random();
|
|
|
|
|
2013-05-21 23:25:01 +08:00
|
|
|
assert!((randmat.inverse() * randmat).approx_eq(&One::one()));
|
2013-05-19 01:04:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_inv_mat3()
|
|
|
|
{
|
|
|
|
for uint::range(0u, 10000u) |_|
|
|
|
|
{
|
|
|
|
let randmat : Mat3<f64> = random();
|
|
|
|
|
2013-05-21 23:25:01 +08:00
|
|
|
assert!((randmat.inverse() * randmat).approx_eq(&One::one()));
|
2013-05-19 01:04:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2013-05-19 19:53:19 +08:00
|
|
|
fn test_rotation2()
|
2013-05-19 01:04:03 +08:00
|
|
|
{
|
2013-05-19 19:53:19 +08:00
|
|
|
for uint::range(0u, 10000u) |_|
|
|
|
|
{
|
|
|
|
let randmat = One::one::<Rotmat<Mat2<f64>>>();
|
|
|
|
let ang = &vec1(abs::<f64>(random()) % f64::consts::pi);
|
|
|
|
|
2013-05-21 23:25:01 +08:00
|
|
|
assert!(randmat.rotated(ang).rotation().approx_eq(ang));
|
2013-05-19 19:53:19 +08:00
|
|
|
}
|
2013-05-19 01:04:03 +08:00
|
|
|
}
|