22
33use core:: ops:: { Add , AddAssign , Div , DivAssign , Mul , MulAssign , Neg , Sub , SubAssign } ;
44use mixed_num:: traits:: * ;
5+ use mixed_num:: MixedAbs ;
6+ type Real = f64 ;
57
68pub mod consts {
79 // We keep the library on f64 for now (simple migration).
@@ -28,7 +30,7 @@ pub struct Vector3<T> {
2830 pub z : T ,
2931}
3032
31- impl < T : MixedNum + MixedOps + Copy > Vector3 < T > {
33+ impl < T : MixedNum + MixedOps + Copy + MixedAbs > Vector3 < T > {
3234 #[ inline]
3335 pub const fn new ( x : T , y : T , z : T ) -> Self { Self { x, y, z } }
3436
@@ -207,17 +209,17 @@ impl<T: MixedNum + MixedOps + Copy> Matrix3<T> {
207209 let det = self . det ( ) ;
208210 if det. mixed_abs ( ) <= eps ( ) { return None ; }
209211 let m = & self . m ;
210- let c00 = ( m[ 1 ] [ 1 ] * m[ 2 ] [ 2 ] - m[ 1 ] [ 2 ] * m[ 2 ] [ 1 ] ) ;
212+ let c00 = m[ 1 ] [ 1 ] * m[ 2 ] [ 2 ] - m[ 1 ] [ 2 ] * m[ 2 ] [ 1 ] ;
211213 let c01 = -( m[ 1 ] [ 0 ] * m[ 2 ] [ 2 ] - m[ 1 ] [ 2 ] * m[ 2 ] [ 0 ] ) ;
212- let c02 = ( m[ 1 ] [ 0 ] * m[ 2 ] [ 1 ] - m[ 1 ] [ 1 ] * m[ 2 ] [ 0 ] ) ;
214+ let c02 = m[ 1 ] [ 0 ] * m[ 2 ] [ 1 ] - m[ 1 ] [ 1 ] * m[ 2 ] [ 0 ] ;
213215
214216 let c10 = -( m[ 0 ] [ 1 ] * m[ 2 ] [ 2 ] - m[ 0 ] [ 2 ] * m[ 2 ] [ 1 ] ) ;
215- let c11 = ( m[ 0 ] [ 0 ] * m[ 2 ] [ 2 ] - m[ 0 ] [ 2 ] * m[ 2 ] [ 0 ] ) ;
217+ let c11 = m[ 0 ] [ 0 ] * m[ 2 ] [ 2 ] - m[ 0 ] [ 2 ] * m[ 2 ] [ 0 ] ;
216218 let c12 = -( m[ 0 ] [ 0 ] * m[ 2 ] [ 1 ] - m[ 0 ] [ 1 ] * m[ 2 ] [ 0 ] ) ;
217219
218- let c20 = ( m[ 0 ] [ 1 ] * m[ 1 ] [ 2 ] - m[ 0 ] [ 2 ] * m[ 1 ] [ 1 ] ) ;
220+ let c20 = m[ 0 ] [ 1 ] * m[ 1 ] [ 2 ] - m[ 0 ] [ 2 ] * m[ 1 ] [ 1 ] ;
219221 let c21 = -( m[ 0 ] [ 0 ] * m[ 1 ] [ 2 ] - m[ 0 ] [ 2 ] * m[ 1 ] [ 0 ] ) ;
220- let c22 = ( m[ 0 ] [ 0 ] * m[ 1 ] [ 1 ] - m[ 0 ] [ 1 ] * m[ 1 ] [ 0 ] ) ;
222+ let c22 = m[ 0 ] [ 0 ] * m[ 1 ] [ 1 ] - m[ 0 ] [ 1 ] * m[ 1 ] [ 0 ] ;
221223
222224 let adj_t = [
223225 [ c00, c10, c20] ,
@@ -310,7 +312,7 @@ impl<T: MixedNum + MixedOps + Copy> Matrix3<T> {
310312 Vector3 :: z ( )
311313 } ;
312314 ortho = f. cross ( ortho) . normalize ( ) ;
313- return Self :: rotation_axis_angle ( ortho, ( T :: mixed_pi ( ) ) ) ;
315+ return Self :: rotation_axis_angle ( ortho, T :: mixed_pi ( ) ) ;
314316 }
315317 }
316318 // Rodrigues without trig: R = I + [v]_x + [v]_x² * ((1 - c)/|v|²)
@@ -559,7 +561,7 @@ impl Rotation3 {
559561 pub fn from_axis_angle ( axis : & Vector3 , angle : Real ) -> Self {
560562 let mut k = * axis;
561563 let n2 = k. dot ( & k) ;
562- if n2 <= EPSILON * EPSILON {
564+ if n2 <= consts :: EPSILON * consts :: EPSILON {
563565 return Self :: identity ( ) ;
564566 }
565567 k /= n2. sqrt ( ) ; // normalize
@@ -591,7 +593,7 @@ impl Rotation3 {
591593 pub fn rotation_between ( a : & Vector3 , b : & Vector3 ) -> Option < Self > {
592594 let la = a. norm ( ) ;
593595 let lb = b. norm ( ) ;
594- if la <= EPSILON || lb <= EPSILON {
596+ if la <= consts :: EPSILON || lb <= consts :: EPSILON {
595597 return None ;
596598 }
597599 let u = * a / la;
@@ -601,7 +603,7 @@ impl Rotation3 {
601603 let axis = u. cross ( & v) ;
602604 let s = axis. norm ( ) ; // |u × v| = sin(theta)
603605
604- if s <= EPSILON {
606+ if s <= consts :: EPSILON {
605607 // Collinear: either identity or 180° turn around any perpendicular axis.
606608 if c > 0.0 {
607609 return Some ( Self :: identity ( ) ) ;
0 commit comments