From fd9ca6cd3f9011af1cd6daf4bc1871393c46d067 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 2 Nov 2023 17:16:34 -0700 Subject: [PATCH] Planar64Vec3::{inverse,transpose,determinant} --- src/integer.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/integer.rs b/src/integer.rs index 9a00886..744958c 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -872,6 +872,41 @@ impl Planar64Mat3{ Planar64Vec3(glam::i64vec3(s,0,c)), ) } + #[inline] + pub const fn inverse(&self)->Self{ + let det= + -self.x_axis.0.z as i128*self.y_axis.0.y as i128*self.z_axis.0.x as i128 + +self.x_axis.0.y as i128*self.y_axis.0.z as i128*self.z_axis.0.x as i128 + +self.x_axis.0.z as i128*self.y_axis.0.x as i128*self.z_axis.0.y as i128 + -self.x_axis.0.x as i128*self.y_axis.0.z as i128*self.z_axis.0.y as i128 + -self.x_axis.0.y as i128*self.y_axis.0.x as i128*self.z_axis.0.z as i128 + +self.x_axis.0.x as i128*self.y_axis.0.y as i128*self.z_axis.0.z as i128 + ; + Self{ + x_axis:Planar64Vec3::raw((((-(self.y_axis.0.z as i128*self.z_axis.0.y as i128)+self.y_axis.0.y as i128*self.z_axis.0.z as i128)<<32)/det) as i64,(((self.x_axis.0.z as i128*self.z_axis.0.y as i128-self.x_axis.0.y as i128*self.z_axis.0.z as i128)<<32)/det) as i64,(((-(self.x_axis.0.z as i128*self.y_axis.0.y as i128)+self.x_axis.0.y as i128*self.y_axis.0.z as i128)<<32)/det) as i64), + y_axis:Planar64Vec3::raw((((self.y_axis.0.z as i128*self.z_axis.0.x as i128-self.y_axis.0.x as i128*self.z_axis.0.z as i128)<<32)/det) as i64,(((-(self.x_axis.0.z as i128*self.z_axis.0.x as i128)+self.x_axis.0.x as i128*self.z_axis.0.z as i128)<<32)/det) as i64,(((self.x_axis.0.z as i128*self.y_axis.0.x as i128-self.x_axis.0.x as i128*self.y_axis.0.z as i128)<<32)/det) as i64), + z_axis:Planar64Vec3::raw((((-(self.y_axis.0.y as i128*self.z_axis.0.x as i128)+self.y_axis.0.x as i128*self.z_axis.0.y as i128)<<32)/det) as i64,(((self.x_axis.0.y as i128*self.z_axis.0.x as i128-self.x_axis.0.x as i128*self.z_axis.0.y as i128)<<32)/det) as i64,(((-(self.x_axis.0.y as i128*self.y_axis.0.x as i128)+self.x_axis.0.x as i128*self.y_axis.0.y as i128)<<32)/det) as i64), + } + } + #[inline] + pub const fn transpose(&self)->Self{ + Self{ + x_axis:Planar64Vec3::raw(self.x_axis.0.x,self.y_axis.0.x,self.z_axis.0.x), + y_axis:Planar64Vec3::raw(self.x_axis.0.y,self.y_axis.0.y,self.z_axis.0.y), + z_axis:Planar64Vec3::raw(self.x_axis.0.z,self.y_axis.0.z,self.z_axis.0.z), + } + } + #[inline] + pub const fn determinant(&self)->Planar64{ + Planar64((( + -self.x_axis.0.z as i128*self.y_axis.0.y as i128*self.z_axis.0.x as i128 + +self.x_axis.0.y as i128*self.y_axis.0.z as i128*self.z_axis.0.x as i128 + +self.x_axis.0.z as i128*self.y_axis.0.x as i128*self.z_axis.0.y as i128 + -self.x_axis.0.x as i128*self.y_axis.0.z as i128*self.z_axis.0.y as i128 + -self.x_axis.0.y as i128*self.y_axis.0.x as i128*self.z_axis.0.z as i128 + +self.x_axis.0.x as i128*self.y_axis.0.y as i128*self.z_axis.0.z as i128 + )>>64) as i64) + } } impl Into for Planar64Mat3{ #[inline]