@@ -551,15 +551,16 @@ impl<Src, Dst> Mat4<Src, Dst> {
551551 /// use retrofire_core::math::*;
552552 ///
553553 /// let m = scale(splat(5.0)).then(&translate3(1.0, 2.0, 3.0));
554- /// let pt = pt3(1.0, 0 .0, 0.0 );
554+ /// let pt = pt3(1.0, -1 .0, 0.5 );
555555 ///
556- /// assert_approx_eq!(m.linear().apply(&pt), pt3(5.0, 0.0, 0.0));
556+ /// // Only the scale is applied because the translate is not linear
557+ /// assert_approx_eq!(m.linear().apply(&pt), pt3(5.0, -5.0, 2.5));
557558 pub const fn linear ( & self ) -> Mat3 < Src , Dst , 3 > {
558559 let [ r, s, t, _] = self . 0 ;
559560 mat ! [
560561 r[ 0 ] , r[ 1 ] , r[ 2 ] ;
561- s[ 0 ] , r [ 1 ] , r [ 2 ] ;
562- t[ 0 ] , r [ 1 ] , r [ 2 ] ;
562+ s[ 0 ] , s [ 1 ] , s [ 2 ] ;
563+ t[ 0 ] , t [ 1 ] , t [ 2 ] ;
563564 ]
564565 }
565566
@@ -1314,7 +1315,7 @@ mod tests {
13141315 #[ allow( unused) ]
13151316 const O : Vec3 = Vec3 :: new ( [ 0.0 ; 3 ] ) ;
13161317
1317- mod mat2x2 {
1318+ mod mat2 {
13181319 use super :: * ;
13191320
13201321 #[ test]
@@ -1348,7 +1349,7 @@ mod tests {
13481349 }
13491350 }
13501351
1351- mod mat3x3 {
1352+ mod mat3 {
13521353 use super :: * ;
13531354
13541355 const MAT : Mat3 < B1 , B2 , 3 > = mat ! [
@@ -1485,6 +1486,24 @@ mod tests {
14851486 assert_eq ! ( MAT . col_vec( 3 ) , [ 3.0 , 13.0 , 23.0 , 33.0 ] . into( ) ) ;
14861487 }
14871488
1489+ #[ test]
1490+ fn linear_part ( ) {
1491+ assert_eq ! (
1492+ MAT . linear( ) ,
1493+ mat![
1494+ 0.0 , 1.0 , 2.0 ;
1495+ 10.0 , 11.0 , 12.0 ;
1496+ 20.0 , 21.0 , 22.0 ;
1497+ ]
1498+ ) ;
1499+ }
1500+
1501+ #[ test]
1502+ fn translation_part ( ) {
1503+ assert_eq ! ( MAT . translation( ) , vec3( 3.0 , 13.0 , 23.0 ) ) ;
1504+ assert_eq ! ( MAT . origin( ) , pt3( 3.0 , 13.0 , 23.0 ) ) ;
1505+ }
1506+
14881507 #[ test]
14891508 fn composition ( ) {
14901509 let tr = translate3 ( 1.0 , 2.0 , 3.0 ) . to :: < Map > ( ) ;
@@ -1637,7 +1656,7 @@ mod tests {
16371656 }
16381657
16391658 #[ test]
1640- fn from_basis ( ) {
1659+ fn from_linear_basis ( ) {
16411660 let m = Mat4 :: from_linear ( Y , 2.0 * Z , -3.0 * X ) ;
16421661
16431662 assert_eq ! ( m. apply( & X ) , Y ) ;
0 commit comments