C4 Engine
C4 Engine API Documentation

class Matrix2D

Defined in:  TSMatrix2D.h
The Matrix2D class encapsulates a 2 × 2 matrix.
Definition

class Matrix2D : public Mat2D<TypeMatrix2D>

Member Functions
Matrix2D::Set Sets all four entries of a matrix.
Matrix2D::SetIdentity Sets a matrix to the 2 × 2 identity matrix.
Matrix2D::Orthogonalize Orthogonalizes the columns of a matrix.
Matrix2D::MakeRotation Returns a matrix that represents a rotation in the 2D plane.
Matrix2D::MakeScale Returns a matrix that represents a scale.
Constructor

Matrix2D();

Matrix2D(float n00, float n01, float n10, float n11);

Matrix2D(const Vector2D& a, const Vector2D& b);

Parameters
nij The value of the entry residing in row i and column j.
a The values of the entries residing in first column.
b The values of the entries residing in second column.
Description
The Matrix2D class is used to store a 2 × 2 matrix. The entries of the matrix are accessed using the () operator with two indexes specifying the row and column of an entry.

The default constructor leaves the entries of the matrix undefined. If the four entries are supplied, then the nij parameter specifies the entry in the i-th row and j-th column. If the matrix is constructed using the two vectors a and b, then these vectors initialize the two columns of the matrix.
Overloaded Operators
floatoperator ()(machine i, machine j); Returns a reference to the entry in the i-th row and j-th column. Both i and j must be 0 or 1.
const floatoperator ()(machine i, machine j) const; Returns a constant reference to the entry in the i-th row and j-th column. Both i and j must be 0 or 1.
Vector2D& operator [](machine j); Returns a reference to the j-th column of a matrix. j must be 0 or 1.
const Vector2D& operator [](machine j) const; Returns a constant reference to the j-th column of a matrix. j must be 0 or 1.
Matrix2D& operator *=(const Matrix2D& m); Multiplies by the matrix m.
Matrix2D& operator *=(float s); Multiplies by the scalar s.
Matrix2D& operator /=(float s); Multiplies by the inverse of the scalar s.
Nonmember Operations
Matrix2D operator *(const Matrix2D& m1, const Matrix2D& m2); Returns the product of the matrices m1 and m2.
Matrix2D operator *(const Matrix2D& m, float s); Returns the product of the matrix m and the scalar s.
Matrix2D operator /(const Matrix2D& m, float s); Returns the product of the matrix m and the inverse of the scalar s.
Vector2D operator *(const Matrix2D& m, const Vector2D& v); Returns the product of the matrix m and the column vector v.
Point2D operator *(const Matrix2D& m, const Point2D& p); Returns the product of the matrix m and the column vector p.
Vector2D operator *(const Vector2D& v, const Matrix2D& m); Returns the product of the row vector v and the matrix m.
float Determinant(const Matrix2D& m); Returns the determinant of the matrix m.
Matrix2D Inverse(const Matrix2D& m); Returns the inverse of the matrix m. If m is singular, then the result is undefined.
Matrix2D Adjugate(const Matrix2D& m); Returns the adjugate of the matrix m.
Base Classes
Mat2D Matrices use a generic base class to store their components.
See Also

Vector2D