Skip to main content

Matrix3x2

The Matrix3x2 type provides a highly optimized and flexible container for 2D affine transformations. It supports efficient storage, manipulation, and composition of transformations such as translation, scaling, and rotation, and is designed for performance-critical applications in graphics, UI, and simulation. Matrix3x2 uses row-major storage with 2 rows and 3 columns.

note

Matrix3x2 has the same alignment as Vector3 type.

info

SIMD types can be used as template parameters for structure of array (SOA) calculations.

#include <math/TellusimMatrix.h>

Matrix3x2f

Represents a 2D affine transformation matrix of 32-bit floating-point numbers.

Matrix3x2d

Represents a 2D affine transformation matrix of 64-bit floating-point numbers.

Variables

TypeNameDescription
Typem00, m01, m02Row 0 components.
Typem10, m11, m12Row 1 components.
Vector3row_0Row 0 vector.
Vector3row_1Row 1 vector.
Vector3rows[2]Vector access.
Typem[3 * 2]Array access.

Constants

TypeNameDescription
Matrix3x2zeroZero matrix.
Matrix3x2identityIdentity matrix.

Constructors

Matrix3x2()
Matrix3x2(const Matrix3x2 &m)
Matrix3x2(const Vector3 &row_0, const Vector3 &row_1)
Matrix3x2(const Vector2 &col_0, const Vector2 &col_1, const Vector2 &col_2)
Matrix3x2(Type m00, Type m01, Type m02, Type m10, Type m11, Type m12)
explicit Matrix3x2(const Type *m, uint32_t size = Size, bool row_major = true)
explicit Matrix3x2(const Matrix3x2<CType> &m)
explicit Matrix3x2(Type v)

Methods

Update matrix data.

void set(const Vector3 &r0, const Vector3 &r1)
void set(const Vector3 &col_0, const Vector3 &col_1, const Vector3 &col_2)
void set(const Type *m, uint32_t size = Size, bool row_major = true)
void get(Type *m, uint32_t size = Size, bool row_major = true) const

Matrix to matrix operators.

Matrix3x2 &operator*=(const Matrix3x2 &m)
Matrix3x2 &operator+=(const Matrix3x2 &m)
Matrix3x2 &operator-=(const Matrix3x2 &m)

Zero matrix.

void setZero()
bool isZero() const

Identity matrix.

void setIdentity()
bool isIdentity() const

Outer product matrix.

void setOuter(const Vector2 &v0, const Vector2 &v1)
static Matrix3x2 outer(const Vector2 &v0, const Vector2 &v1)

Scaling matrix.

void setScale(const Vector2 &s)
void setScale(Type x, Type y)
Vector2 getScale() const
static Matrix3x2 scale(const Vector2 &s)
static Matrix3x2 scale(Type x, Type y)
static Matrix3x2 scale(Type s)

Translation matrix.

void setTranslate(const Vector2 &t)
void setTranslate(Type x, Type y)
Vector2 getTranslate() const
static Matrix3x2 translate(const Vector2 &t)
static Matrix3x2 translate(Type x, Type y)

Rotation matrix.

void setRotate(Type angle)
Matrix3x2 getRotate() const
static Matrix3x2 rotate(Type angle)

Matrix determinant.

Type getDeterminant() const

Matrix composition.

void setComponents(const Vector2 &t, Type r, const Vector2 &scale)
void getComponents(Vector2 &t, Type &r, Vector2 &s) const
static Matrix3x2 compose(const Vector2 &t, Type r, const Vector2 &s)

Matrix rows.

void setRow(uint32_t index, const Vector3 &r)
const Vector3 &getRow(uint32_t index) const
Vector3 &getRow(uint32_t index)

Matrix columns.

void setColumn(uint32_t index, const Vector2 &c)
Vector2 getColumn(uint32_t index) const

Matrix data.

const Vector3 &operator[](uint32_t index) const
Vector3 &operator[](uint32_t index)

Operators

Unary operators.

Matrix3x2 operator-(const Matrix3x2 &m)

Matrix to scalar multiplication.

Matrix3x2 operator*(const Matrix3x2 &m, const Type &v)

Matrix to vector multiplications.

Vector2 operator*(const Matrix3x2 &m, const Vector2 &v)
Vector2 mul2x2(const Matrix3x2 &m, const Vector2 &v)

Vector to matrix multiplications.

Vector2 operator*(const Vector2 &v, const Matrix3x2 &m)

Matrix to matrix multiplications.

Matrix3x2 operator*(const Matrix3x2 &m0, const Matrix3x2 &m1)

Matrix to matrix operators.

Matrix3x2 operator+(const Matrix3x2 &m0, const Matrix3x2 &m1)
Matrix3x2 operator-(const Matrix3x2 &m0, const Matrix3x2 &m1)

Comparison operators.

bool operator==(const Matrix3x2 &m0, const Matrix3x2 &m1)
bool operator!=(const Matrix3x2 &m0, const Matrix3x2 &m1)
bool compare(const Matrix3x2 &m0, const Matrix3x2 &m1, const Type &a)
bool compare(const Matrix3x2 &m0, const Matrix3x2 &m1, const Type &a, const Type &r)

Functions

Matrix functions.

Matrix3x2 transpose(const Matrix3x2 &m)
Matrix3x2 inverse(const Matrix3x2 &m)