commit 6f674784ee79dd49d935ff6532d859092eb95a52 parent 47831cd14540339593bef496e9e398b4ce0ed49b Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Nov 13 22:10:24 +0200 Use v2 rows instead of floats in m2 Diffstat:
linear_algebra.h | | | 22 | +++++++++------------- |
diff --git a/linear_algebra.h b/linear_algebra.h @@ -35,21 +35,17 @@ struct v2 { }; struct m2 { - float a, b, c, d; + v2 row0, row1; m2() { } - explicit m2( float a_, float b_, float c_, float d_ ) { - a = a_; - b = b_; - c = c_; - d = d_; + explicit m2( float e0, float e1, float e2, float e3 ) { + row0 = v2( e0, e1 ); + row1 = v2( e2, e3 ); } - v2 row0() const { return v2( a, b ); } - v2 row1() const { return v2( c, d ); } - v2 col0() const { return v2( a, c ); } - v2 col1() const { return v2( b, d ); } + v2 col0() const { return v2( row0.x, row1.x ); } + v2 col1() const { return v2( row0.y, row1.y ); } }; struct v3 { @@ -274,13 +270,13 @@ forceinline m2 m2_scale( float x, float y ) { forceinline m2 operator*( const m2 & lhs, const m2 & rhs ) { return m2( - dot( lhs.row0(), rhs.col0() ), dot( lhs.row0(), rhs.col1() ), - dot( lhs.row1(), rhs.col0() ), dot( lhs.row1(), rhs.col1() ) + dot( lhs.row0, rhs.col0() ), dot( lhs.row0, rhs.col1() ), + dot( lhs.row1, rhs.col0() ), dot( lhs.row1, rhs.col1() ) ); } forceinline v2 operator*( const m2 & m, v2 v ) { - return v2( dot( m.row0(), v ), dot( m.row1(), v ) ); + return v2( dot( m.row0, v ), dot( m.row1, v ) ); } /*