Fix bug when trying to create a rotation matrix with a zero angle.
This commit is contained in:
parent
02e22717a4
commit
6fd9696253
|
@ -36,6 +36,10 @@ pub fn rotmat2<N: Copy + Trigonometric + Neg<N>>(angle: N) -> Rotmat<Mat2<N>>
|
||||||
|
|
||||||
pub fn rotmat3<N: Copy + Trigonometric + DivisionRing + Algebraic>
|
pub fn rotmat3<N: Copy + Trigonometric + DivisionRing + Algebraic>
|
||||||
(axisangle: Vec3<N>) -> Rotmat<Mat3<N>>
|
(axisangle: Vec3<N>) -> Rotmat<Mat3<N>>
|
||||||
|
{
|
||||||
|
if axisangle.sqnorm().is_zero()
|
||||||
|
{ One::one() }
|
||||||
|
else
|
||||||
{
|
{
|
||||||
let mut axis = axisangle;
|
let mut axis = axisangle;
|
||||||
let angle = axis.normalize();
|
let angle = axis.normalize();
|
||||||
|
@ -65,6 +69,7 @@ pub fn rotmat3<N: Copy + Trigonometric + DivisionRing + Algebraic>
|
||||||
(sqz + (_1 - sqz) * cos) ] )
|
(sqz + (_1 - sqz) * cos) ] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<N: Trigonometric + DivisionRing + Copy>
|
impl<N: Trigonometric + DivisionRing + Copy>
|
||||||
Rotation<Vec1<N>> for Rotmat<Mat2<N>>
|
Rotation<Vec1<N>> for Rotmat<Mat2<N>>
|
||||||
|
|
|
@ -15,7 +15,7 @@ use traits::transpose::Transpose;
|
||||||
#[test]
|
#[test]
|
||||||
use vec::Vec1;
|
use vec::Vec1;
|
||||||
#[test]
|
#[test]
|
||||||
use mat::{Mat1, Mat2, Mat3};
|
use mat::{Mat1, Mat2, Mat3, Mat4, Mat5, Mat6};
|
||||||
#[test]
|
#[test]
|
||||||
use adaptors::rotmat::Rotmat;
|
use adaptors::rotmat::Rotmat;
|
||||||
|
|
||||||
|
@ -42,10 +42,17 @@ fn test_inv_mat2()
|
||||||
fn test_inv_mat3()
|
fn test_inv_mat3()
|
||||||
{ test_inv_mat_impl!(Mat3<f64>); }
|
{ test_inv_mat_impl!(Mat3<f64>); }
|
||||||
|
|
||||||
// FIXME: ICE
|
#[test]
|
||||||
// #[test]
|
fn test_inv_mat4()
|
||||||
// fn test_inv_nmat()
|
{ test_inv_mat_impl!(Mat4<f64>); }
|
||||||
// { test_inv_mat_impl!(NMat<d7, f64>); }
|
|
||||||
|
#[test]
|
||||||
|
fn test_inv_mat5()
|
||||||
|
{ test_inv_mat_impl!(Mat5<f64>); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_inv_mat6()
|
||||||
|
{ test_inv_mat_impl!(Mat6<f64>); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rotation2()
|
fn test_rotation2()
|
||||||
|
|
Loading…
Reference in New Issue