libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Matrix3x3 Class Reference

A 3x3 floating-point matrix with SSE-accelerated operations. More...

#include <matrix3x3.h>

Public Member Functions

 Matrix3x3 ()
 Constructs a zero-initialized matrix.
 
 Matrix3x3 (float val[3][3])
 Constructs a matrix from a 3x3 float array.
 
Matrix3x3 operator+ (const Matrix3x3 &other) const
 Returns the element-wise sum of two matrices.
 
Matrix3x3 operator- (const Matrix3x3 &other) const
 Returns the element-wise difference of two matrices.
 
Matrix3x3 operator* (const Matrix3x3 &other) const
 Returns the matrix product of two matrices.
 
float dot (int row1, int row2) const
 Computes the dot product of two rows in this matrix.
 
void zero ()
 Sets all matrix elements to zero.
 
void set (float val[3][3])
 Copies values from a 3x3 float array into this matrix.
 
Matrix3x3 transpose () const
 Returns the transpose of this matrix.
 
float determinant () const
 Computes the determinant of this matrix.
 
Matrix3x3 inverse () const
 Computes the inverse of this matrix.
 
float trace () const
 Computes the trace (sum of diagonal elements) of this matrix.
 
Matrix3x3 operator* (float scalar) const
 Multiplies every element by a scalar.
 
Matrix3x3 operator/ (float scalar) const
 Divides every element by a scalar.
 
bool operator== (const Matrix3x3 &other) const
 Returns true if all elements are equal to the other matrix.
 
bool operator!= (const Matrix3x3 &other) const
 Returns true if any element differs from the other matrix.
 
float get (int row, int col) const
 Returns the element at the given row and column.
 
void set (int row, int col, float value)
 Sets the element at the given row and column.
 
Matrix3x3 elementMultiply (const Matrix3x3 &other) const
 Returns the Hadamard (element-wise) product of two matrices.
 
Matrix3x3 elementDivide (const Matrix3x3 &other) const
 Returns the element-wise quotient of two matrices.
 
void vectorTransform (float vector[3]) const
 Transforms a 3-element vector by this matrix in place.
 

Static Public Member Functions

static Matrix3x3 scalingMatrix (float scale_x, float scale_y, float scale_z)
 Creates a diagonal scaling matrix.
 
static Matrix3x3 rotationMatrix (float angle, char axis)
 Creates a rotation matrix around the specified axis.
 

Static Public Attributes

static constexpr float IdentityMatrix [3][3]
 The 3x3 identity matrix constant.
 

Detailed Description

A 3x3 floating-point matrix with SSE-accelerated operations.

Provides standard linear algebra operations including addition, subtraction, multiplication, transpose, inverse, and determinant. Element-wise operations and vector transforms are also supported. Uses SSE intrinsics where beneficial.

Constructor & Destructor Documentation

◆ Matrix3x3()

Matrix3x3::Matrix3x3 ( float  val[3][3])
inline

Constructs a matrix from a 3x3 float array.

Parameters
valThe source array to copy values from.

Member Function Documentation

◆ determinant()

float Matrix3x3::determinant ( ) const
inline

Computes the determinant of this matrix.

Returns
The determinant value.

◆ dot()

float Matrix3x3::dot ( int  row1,
int  row2 
) const
inline

Computes the dot product of two rows in this matrix.

Parameters
row1Index of the first row (0-2).
row2Index of the second row (0-2).
Returns
The dot product of the two row vectors.

◆ elementDivide()

Matrix3x3 Matrix3x3::elementDivide ( const Matrix3x3 other) const
inline

Returns the element-wise quotient of two matrices.

Division by zero for individual elements produces zero rather than NaN.

Parameters
otherThe divisor matrix.
Returns
The element-wise quotient matrix.

◆ elementMultiply()

Matrix3x3 Matrix3x3::elementMultiply ( const Matrix3x3 other) const
inline

Returns the Hadamard (element-wise) product of two matrices.

Parameters
otherThe matrix to multiply element-wise.
Returns
The element-wise product matrix.

◆ get()

float Matrix3x3::get ( int  row,
int  col 
) const
inline

Returns the element at the given row and column.

Parameters
rowThe row index (0-2).
colThe column index (0-2).
Returns
The element value, or 0.0f if the indices are out of range.

◆ inverse()

Matrix3x3 Matrix3x3::inverse ( ) const
inline

Computes the inverse of this matrix.

Returns
The inverse matrix, or a zero matrix if the matrix is singular.

◆ operator*() [1/2]

Matrix3x3 Matrix3x3::operator* ( const Matrix3x3 other) const
inline

Returns the matrix product of two matrices.

Parameters
otherThe right-hand matrix.
Returns
The resulting product matrix.

◆ operator*() [2/2]

Matrix3x3 Matrix3x3::operator* ( float  scalar) const
inline

Multiplies every element by a scalar.

Parameters
scalarThe scalar multiplier.
Returns
The scaled matrix.

◆ operator+()

Matrix3x3 Matrix3x3::operator+ ( const Matrix3x3 other) const
inline

Returns the element-wise sum of two matrices.

Parameters
otherThe matrix to add.
Returns
The resulting sum matrix.

◆ operator-()

Matrix3x3 Matrix3x3::operator- ( const Matrix3x3 other) const
inline

Returns the element-wise difference of two matrices.

Parameters
otherThe matrix to subtract.
Returns
The resulting difference matrix.

◆ operator/()

Matrix3x3 Matrix3x3::operator/ ( float  scalar) const
inline

Divides every element by a scalar.

Parameters
scalarThe scalar divisor. Returns a zero matrix if zero.
Returns
The divided matrix.

◆ rotationMatrix()

static Matrix3x3 Matrix3x3::rotationMatrix ( float  angle,
char  axis 
)
inlinestatic

Creates a rotation matrix around the specified axis.

Parameters
angleThe rotation angle in radians.
axisThe axis of rotation ('x', 'y', or 'z'). Returns identity for invalid axes.
Returns
The rotation matrix.

◆ scalingMatrix()

static Matrix3x3 Matrix3x3::scalingMatrix ( float  scale_x,
float  scale_y,
float  scale_z 
)
inlinestatic

Creates a diagonal scaling matrix.

Parameters
scale_xScale factor along the X axis.
scale_yScale factor along the Y axis.
scale_zScale factor along the Z axis.
Returns
The scaling matrix.

◆ set() [1/2]

void Matrix3x3::set ( float  val[3][3])
inline

Copies values from a 3x3 float array into this matrix.

Parameters
valThe source array.

◆ set() [2/2]

void Matrix3x3::set ( int  row,
int  col,
float  value 
)
inline

Sets the element at the given row and column.

Parameters
rowThe row index (0-2).
colThe column index (0-2).
valueThe value to set. Ignored if indices are out of range.

◆ trace()

float Matrix3x3::trace ( ) const
inline

Computes the trace (sum of diagonal elements) of this matrix.

Returns
The trace value.

◆ transpose()

Matrix3x3 Matrix3x3::transpose ( ) const
inline

Returns the transpose of this matrix.

Returns
The transposed matrix.

◆ vectorTransform()

void Matrix3x3::vectorTransform ( float  vector[3]) const
inline

Transforms a 3-element vector by this matrix in place.

Parameters
vectorA 3-element float array that is multiplied by this matrix.

Member Data Documentation

◆ IdentityMatrix

constexpr float Matrix3x3::IdentityMatrix[3][3]
staticconstexpr
Initial value:
= {
{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 1.0f}
}

The 3x3 identity matrix constant.


The documentation for this class was generated from the following file: