#![allow(bad_style)] #![allow(clippy::float_cmp)] //! "Mat Mul-vec" is the 4th-wall-breaking brother of "Vec Mul-vec" use hektor::*; #[test] fn Mat2_mul_Vec2() { let m = Mat2::diagonal(1.0, 1.0); let v = Vec2::new(3.0, 5.0); assert_eq!(m * v, v); // let m = Mat2::from([1.0, 2.0, 3.0, 4.0]); let v = Vec2::new(3.0, 5.0); assert_eq!(m * v, Vec2::new(18.0, 26.0)); } #[test] fn Mat3_mul_Vec3() { let m = Mat3::diagonal(1.0, 1.0, 1.0); let v = Vec3::new(3.0, 5.0, 10.0); assert_eq!(m * v, v); // let m = Mat3::from([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]); let v = Vec3::new(3.0, 5.0, -2.0); assert_eq!(m * v, Vec3::new(9.0, 15.0, 21.0)); } #[test] fn Mat4_mul_Vec4() { let m = Mat4::diagonal(1.0, 1.0, 1.0, 1.0); let v = Vec4::new(3.0, 5.0, 10.0, -7.0); assert_eq!(m * v, v); // let m = Mat4::from([ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ]); let v = Vec4::new(3.0, 5.0, -2.0, 1.0); assert_eq!(m * v, Vec4::new(23.0, 30.0, 37.0, 44.0)); }