``````Matrix2D ( const Matrix2D& );
Matrix2D& operator = ( const Matrix2D& );
Matrix2D& operator = ( float );
Matrix2D& operator += ( const Matrix2D& );
Matrix2D& operator -= (' const Matrix2D& );
Matrix2D& operator *= ( const Matrix2D& );
Matrix2D& operator *= ( float );
Matrix2D& operator /= ( float );
const float * operator [] ( int i ) const {
return & x[i][0];
}``````
``````float * operator [] ( int i ) (
return & x[i] [0];
}
Matrix2D& invert (); Matrix2D& transpose () ;
float det () const {
return x [0] [0] * x [1] [1] - x [0] [1] * x [1] [0] ;
}
Matrix2D getlnverse () const {
return Matrix2D ( *this ).invert ();
}
static Matrix2D getldentityMatrix () ;
static Matrix2D getScaleMatrix ( const Vector2D& ); static Matrix2D getRotateMatrix ( float ); static Matrix2D getMirrorXMatrix (); static Matrix2D getMirrorYMatrix () ;
friend Matrix2D operator + ( const Matrix2D&,
const Matrix2D& );
friend Matrix2D operator - ( const Matrix2D&,
const Matrix2D& );
friend Matrix2D operator * ( const Matrix2D&,
const Matrix2D& );
friend Matrix2D operator * ( const Matrix2D&, float ); friend Matrix2D operator * ( float, const Matrix2D& );
friend Vector2D operator * ( const Matrix2D&,
const Vector2D& );
};``````

Удобно создать также класс для работы с произвольными аффинными преобразованиями.

У

``````class Transform2D {
public:
Matrix2D m; // linear transform matrix
Vector2D v; // translation vector``````

Глава I. Координаты и их преобразования

``````Transform2D () {}
Transform2D ( const Matrix2D matrix,
const Vector2D& vector ) : m ( matrix ), v ( vector ) {}
Transform2D ( const Transform2D& tr ) :
m ( tr.m ) , v ( tr.v ) {} :.``````

⇐ Предыдущая| |Следующая ⇒