Matrix4x3
The Matrix4x3 type provides a highly optimized and flexible container for 3D affine transformations. It supports efficient storage, manipulation, and composition of transformations such as translation, rotation, and scaling, and is designed for performance-critical applications in 3D graphics and simulation. Matrix4x3 uses row-major storage with 3 rows and 4 columns, omitting the final row of a full 4x4 matrix to reduce memory usage and improve performance when homogeneous coordinates are implicitly assumed.
Matrix4x3 has a 16-byte alignment to ensure optimal performance and compatibility with SIMD operations.
SIMD types can be used as template parameters for structure of array (SOA) calculations.
#include <math/TellusimMatrix.h>
Matrix4x3f
Represents a 3D affine transformation matrix of 32-bit floating-point numbers.
Matrix4x3d
Represents a 3D affine transformation matrix of 64-bit floating-point numbers.
Variables
Type | Name | Description |
---|---|---|
Type | m00, m01, m02, m03 | Row 0 components. |
Type | m10, m11, m12, m13 | Row 1 components. |
Type | m20, m21, m22, m23 | Row 2 components. |
Vector4 | row_0 | Row 0 vector. |
Vector4 | row_1 | Row 1 vector. |
Vector4 | row_2 | Row 2 vector. |
Vector4 | rows[3] | Vector access. |
Type | m[4 * 3] | Array access. |
Constants
Type | Name | Description |
---|---|---|
Matrix4x3 | zero | Zero matrix. |
Matrix4x3 | identity | Identity matrix. |
Constructors
Matrix4x3()
Matrix4x3(const Matrix4x3 &m)
Matrix4x3(const Vector4 &row_0, const Vector4 &row_1, const Vector4 &row_2)
Matrix4x3(const Vector3 &col_0, const Vector3 &col_1, const Vector3 &col_2, const Vector3 &col_3)
Matrix4x3(Type m00, Type m01, Type m02, Type m03, Type m10, Type m11, Type m12, Type m13, Type m20, Type m21, Type m22, Type m23)
explicit Matrix4x3(const Matrix4x4 &m)
explicit Matrix4x3(const Quaternion &q)
explicit Matrix4x3(const Type *m, uint32_t size = Size, bool row_major = true)
explicit Matrix4x3(const Matrix4x3<CType> &m)
explicit Matrix4x3(const Matrix4x4<CType> &m)
explicit Matrix4x3(Type v)
Methods
Update matrix data.
void set(const Vector4 &r0, const Vector4 &r1, const Vector4 &r2)
void set(const Vector3 &col_0, const Vector3 &col_1, const Vector3 &col_2, const Vector3 &col_3)
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.
Matrix4x3 &operator*=(const Matrix4x3 &m)
Matrix4x3 &operator+=(const Matrix4x3 &m)
Matrix4x3 &operator-=(const Matrix4x3 &m)
Zero matrix.
void setZero()
bool isZero() const
Identity matrix.
void setIdentity()
bool isIdentity() const
Outer product matrix.
void setOuter(const Vector3 &v0, const Vector3 &v1)
static Matrix4x3 outer(const Vector3 &v0, const Vector3 &v1)
Scaling matrix.
void setScale(const Vector3 &s)
void setScale(Type x, Type y, Type z)
Vector3 getScale() const
static Matrix4x3 scale(const Vector3 &s)
static Matrix4x3 scale(Type x, Type y, Type z)
static Matrix4x3 scale(Type s)
Translation matrix.
void setTranslate(const Vector3 &t)
void setTranslate(Type x, Type y, Type z)
Vector3 getTranslate() const
static Matrix4x3 translate(const Vector3 &t)
static Matrix4x3 translate(Type x, Type y, Type z)
Rotation matrix.
void setRotateX(Type angle)
void setRotateY(Type angle)
void setRotateZ(Type angle)
void setRotate(const Vector3 &axis, Type angle)
void setRotate(Type x, Type y, Type z, Type angle)
Matrix4x3 getRotate() const
static Matrix4x3 rotateX(Type angle)
static Matrix4x3 rotateY(Type angle)
static Matrix4x3 rotateZ(Type angle)
static Matrix4x3 rotate(const Vector3 &axis, Type angle)
static Matrix4x3 rotate(Type x, Type y, Type z, Type angle)
Look at matrix.
void setLookAt(const Vector3 &from, const Vector3 &to, const Vector3 &up)
static Matrix4x3 lookAt(const Vector3 &from, const Vector3 &to, const Vector3 &up)
Place to matrix.
void setPlaceTo(const Vector3 &to, const Vector3 &from, const Vector3 &up)
static Matrix4x3 placeTo(const Vector3 &to, const Vector3 &from, const Vector3 &up)
Cube at matrix.
void setCubeAt(const Vector3 &from, uint32_t face)
static Matrix4x3 cubeAt(const Vector3 &from, uint32_t face)
Right-handed orthonormal basis.
void setBasis(const Vector3 &normal, const Vector3 &t)
static Matrix4x3 basis(const Vector3 &normal)
static Matrix4x3 basis(const Vector3 &normal, const Vector3 &t)
Matrix determinant.
Type getDeterminant() const
Matrix composition.
void setComponents(const Vector3 &t, const Quaternion &r)
void setComponents(const Vector3 &t, const Quaternion &r, const Vector3 &s)
void getComponents(Vector3 &t, Quaternion &r) const
void getComponents(Vector3 &t, Quaternion &r, Vector3 &s) const
static Matrix4x3 compose(const Vector3 &t, const Quaternion &r)
static Matrix4x3 compose(const Vector3 &t, const Quaternion &r, const Vector3 &s)
Matrix rows.
void setRow(uint32_t index, const Vector4 &r)
const Vector4 &getRow(uint32_t index) const
Vector4 &getRow(uint32_t index)
Matrix columns.
void setColumn(uint32_t index, const Vector3 &c)
Vector3 getColumn(uint32_t index) const
Matrix data.
const Vector4 &operator[](uint32_t index) const
Vector4 &operator[](uint32_t index)
Operators
Unary operators.
Matrix4x3 operator-(const Matrix4x3 &m)
Matrix to scalar multiplication.
Matrix4x3 operator*(const Matrix4x3 &m, const Type &v)
Matrix to vector multiplications.
Vector2 operator*(const Matrix4x3 &m, const Vector2 &v)
Vector3 operator*(const Matrix4x3 &m, const Vector3 &v)
Vector4 operator*(const Matrix4x3 &m, const Vector4 &v)
Vector2 mul2x2(const Matrix4x3 &m, const Vector2 &v)
Vector3 mul3x3(const Matrix4x3 &m, const Vector3 &v)
Vector to matrix multiplications.
Vector2 operator*(const Vector2 &v, const Matrix4x3 &m)
Vector3 operator*(const Vector3 &v, const Matrix4x3 &m)
Vector4 operator*(const Vector4 &v, const Matrix4x3 &m)
Matrix to matrix multiplications.
Matrix4x3 operator*(const Matrix4x3 &m0, const Matrix4x3 &m1)
Matrix to matrix operators.
Matrix4x3 operator+(const Matrix4x3 &m0, const Matrix4x3 &m1)
Matrix4x3 operator-(const Matrix4x3 &m0, const Matrix4x3 &m1)
Comparison operators.
bool operator==(const Matrix4x3 &m0, const Matrix4x3 &m1)
bool operator!=(const Matrix4x3 &m0, const Matrix4x3 &m1)
bool compare(const Matrix4x3 &m0, const Matrix4x3 &m1, const Type &a)
bool compare(const Matrix4x3 &m0, const Matrix4x3 &m1, const Type &a, const Type &r)
Functions
Matrix functions.
Matrix4x3 normalize(const Matrix4x3 &m)
Matrix4x3 transpose(const Matrix4x3 &m)
Matrix4x3 inverse(const Matrix4x3 &m)
Matrix4x3 inverse33(const Matrix4x3 &m)
Matrix4x3 lerp(const Matrix4x3 &m0, const Matrix4x3 &m1, float32_t k)
Matrix4x3 jacobi(const Matrix4x3 &m, Matrix4x3 &v, float32_t threshold = 1e-6f)