use na::{self, U2, U3, U4, Matrix3, Matrix4}; use traits::Number; use aliases::{Mat, Vec}; pub fn proj2D(m: &Mat, normal: &Vec) -> Mat { let mut res = Matrix3::identity(); { let mut part = res.fixed_slice_mut::(0, 0); part -= normal * normal.transpose(); } res } pub fn proj3D(m: &Mat, normal: &Vec) -> Mat { let mut res = Matrix4::identity(); { let mut part = res.fixed_slice_mut::(0, 0); part -= normal * normal.transpose(); } res } pub fn reflect2D(m: &Mat, normal: &Vec) -> Mat { let mut res = Matrix3::identity(); { let mut part = res.fixed_slice_mut::(0, 0); part -= (normal * N::from_f64(2.0).unwrap()) * normal.transpose(); } res } pub fn reflect3D(m: &Mat, normal: &Vec) -> Mat { let mut res = Matrix4::identity(); { let mut part = res.fixed_slice_mut::(0, 0); part -= (normal * N::from_f64(2.0).unwrap()) * normal.transpose(); } res } pub fn scaleBias(scale: N, bias: N) -> Mat { let _0 = N::zero(); let _1 = N::one(); Matrix4::new( scale, _0, _0, bias, _0, scale, _0, bias, _0, _0, scale, bias, _0, _0, _0, _1, ) } pub fn scaleBias2(m: &Mat, scale: N, bias: N) -> Mat { m * scaleBias(scale, bias) } pub fn shearX2D(m: &Mat, y: N) -> Mat { let _0 = N::zero(); let _1 = N::one(); let shear = Matrix3::new( _1, y, _0, _0, _1, _0, _0, _0, _1 ); m * shear } pub fn shearX3D(m: &Mat, y: N, z: N) -> Mat { let _0 = N::zero(); let _1 = N::one(); let shear = Matrix4::new( _1, _0, _0, _0, y, _1, _0, _0, z, _0, _1, _0, _0, _0, _0, _1, ); m * shear } pub fn shearY2D(m: &Mat, x: N) -> Mat { let _0 = N::zero(); let _1 = N::one(); let shear = Matrix3::new( _1, _0, _0, x, _1, _0, _0, _0, _1 ); m * shear } pub fn shearY3D(m: &Mat, x: N, z: N) -> Mat { let _0 = N::zero(); let _1 = N::one(); let shear = Matrix4::new( _1, x, _0, _0, _0, _1, _0, _0, _0, z, _1, _0, _0, _0, _0, _1, ); m * shear } pub fn shearZ3D(m: &Mat, x: N, y: N) -> Mat { let _0 = N::zero(); let _1 = N::one(); let shear = Matrix4::new( _1, _0, x, _0, _0, _1, y, _0, _0, _0, _1, _0, _0, _0, _0, _1, ); m * shear }