30#include <math/vector2d.h>
84 MATRIX3x3( T a00, T a01, T a02, T a10, T a11, T a12, T a20, T a21, T a22 );
159 friend std::ostream& operator<<<T>( std::ostream& aStream,
const MATRIX3x3<T>& aMatrix );
182 for(
int j = 0; j < 3; j++ )
184 for(
int i = 0; i < 3; i++ )
212 for(
int j = 0; j < 3; j++ )
214 for(
int i = 0; i < 3; i++ )
228 m_data[0][2] = aTranslation.x;
229 m_data[1][2] = aTranslation.y;
237 result.x = m_data[0][2];
238 result.y = m_data[1][2];
247 T cosValue = cos( aAngle );
248 T sinValue = sin( aAngle );
249 m_data[0][0] = cosValue;
250 m_data[0][1] = -sinValue;
251 m_data[1][0] = sinValue;
252 m_data[1][1] = cosValue;
259 m_data[0][0] = aScale.x;
260 m_data[1][1] = aScale.y;
267 VECTOR2<T> result( m_data[0][0], m_data[1][1] );
278 for(
int i = 0; i < 3; i++ )
280 for(
int j = 0; j < 3; j++ )
282 result.m_data[i][j] = aA.m_data[i][0] * aB.m_data[0][j] +
283 aA.m_data[i][1] * aB.m_data[1][j] +
284 aA.m_data[i][2] * aB.m_data[2][j];
296 result.x = aMatrix.m_data[0][0] * aVector.x + aMatrix.m_data[0][1] * aVector.y
297 + aMatrix.m_data[0][2];
298 result.y = aMatrix.m_data[1][0] * aVector.x + aMatrix.m_data[1][1] * aVector.y
299 + aMatrix.m_data[1][2];
308 return m_data[0][0] * ( m_data[1][1] * m_data[2][2] - m_data[1][2] * m_data[2][1] )
309 - m_data[0][1] * ( m_data[1][0] * m_data[2][2] - m_data[1][2] * m_data[2][0] )
310 + m_data[0][2] * ( m_data[1][0] * m_data[2][1] - m_data[1][1] * m_data[2][0] );
314template <
class T,
class S>
319 for(
int i = 0; i < 3; i++ )
321 for(
int j = 0; j < 3; j++ )
323 result.m_data[i][j] = aMatrix.m_data[i][j] * aScalar;
331template <
class T,
class S>
334 return aMatrix * aScalar;
343 result.m_data[0][0] = m_data[1][1] * m_data[2][2] - m_data[2][1] * m_data[1][2];
344 result.m_data[0][1] = m_data[0][2] * m_data[2][1] - m_data[2][2] * m_data[0][1];
345 result.m_data[0][2] = m_data[0][1] * m_data[1][2] - m_data[1][1] * m_data[0][2];
347 result.m_data[1][0] = m_data[1][2] * m_data[2][0] - m_data[2][2] * m_data[1][0];
348 result.m_data[1][1] = m_data[0][0] * m_data[2][2] - m_data[2][0] * m_data[0][2];
349 result.m_data[1][2] = m_data[0][2] * m_data[1][0] - m_data[1][2] * m_data[0][0];
351 result.m_data[2][0] = m_data[1][0] * m_data[2][1] - m_data[2][0] * m_data[1][1];
352 result.m_data[2][1] = m_data[0][1] * m_data[2][0] - m_data[2][1] * m_data[0][0];
353 result.m_data[2][2] = m_data[0][0] * m_data[1][1] - m_data[1][0] * m_data[0][1];
355 return result * ( 1.0 / Determinant() );
364 for(
int i = 0; i < 3; i++ )
366 for(
int j = 0; j < 3; j++ )
368 result.m_data[j][i] = m_data[i][j];
377std::ostream& operator<<( std::ostream& aStream,
const MATRIX3x3<T>& aMatrix )
379 for(
int i = 0; i < 3; i++ )
383 for(
int j = 0; j < 3; j++ )
385 aStream << aMatrix.m_data[i][j];
MATRIX3x3 describes a general 3x3 matrix.
Definition matrix3x3.h:62
VECTOR2< T > GetTranslation() const
Get the translation components of the matrix.
Definition matrix3x3.h:234
MATRIX3x3 Transpose() const
Get the transpose of the matrix.
Definition matrix3x3.h:360
void SetIdentity()
Set the matrix to the identity matrix.
Definition matrix3x3.h:210
friend std::ostream & operator<<(std::ostream &aStream, const MATRIX3x3< T > &aMatrix)
Output to a stream.
Definition matrix3x3.h:377
void SetRotation(T aAngle)
Set the rotation components of the matrix.
Definition matrix3x3.h:245
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
Definition matrix3x3.h:257
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition matrix3x3.h:265
MATRIX3x3()
Initialize all matrix members to zero.
Definition matrix3x3.h:180
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
Definition matrix3x3.h:226
T Determinant() const
Compute the determinant of the matrix.
Definition matrix3x3.h:306
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition matrix3x3.h:339
Define a general 2D-vector/point.
Definition vector2d.h:72
Point operator*(double s, const Point &a)
Multiply point by scalar.
Definition shapes.h:250