From 1a5a48d3035af0e651b5c7c32404bba3f7044d6a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 13 Sep 2024 13:22:00 -0700 Subject: [PATCH] dedicated affine type means less math --- src/integer.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/integer.rs b/src/integer.rs index 3463ce6..52017ea 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -440,9 +440,9 @@ impl TryFrom<[f32;3]> for Unit32Vec3{ pub type Planar64=fixed_wide::types::I32F32; pub type Planar64Vec3=linear_ops::types::Vector3; pub type Planar64Mat3=linear_ops::types::Matrix3; -pub type Planar64Affine3=linear_ops::types::Matrix4x3; pub mod vec3{ use super::*; + pub use linear_ops::types::Vector3; pub const ZERO:Planar64Vec3=Planar64Vec3::new([Planar64::ZERO;3]); pub const ZERO_2:linear_ops::types::Vector3>=linear_ops::types::Vector3::new([Fixed::<2,64>::ZERO;3]); pub const X:Planar64Vec3=Planar64Vec3::new([Planar64::ONE,Planar64::ZERO,Planar64::ZERO]); @@ -464,6 +464,7 @@ pub fn int(value:i32)->Planar64{ } pub mod mat3{ use super::*; + pub use linear_ops::types::Matrix3; pub fn from_diagonal(diag:Planar64Vec3)->Planar64Mat3{ Planar64Mat3::new([ [diag.x,Planar64::ZERO,Planar64::ZERO], @@ -479,6 +480,22 @@ pub mod mat3{ } } +#[derive(Clone,Copy,Default,Hash,Eq,PartialEq)] +pub struct Planar64Affine3{ + pub matrix3:Planar64Mat3,//includes scale above 1 + pub translation:Planar64Vec3, +} +impl Planar64Affine3{ + #[inline] + pub const fn new(matrix3:Planar64Mat3,translation:Planar64Vec3)->Self{ + Self{matrix3,translation} + } + #[inline] + pub fn transform_point3(&self,point:Planar64Vec3)->vec3::Vector3>{ + self.translation.fix_2()+self.matrix3*point + } +} + #[test] fn test_sqrt(){ let r=int(400);