Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Matrix3x4 Class Reference

#include <Matrix3x4.h>

Public Types

using Axis = Constants::Axis
 

Public Member Functions

 AZ_TYPE_INFO (Matrix3x4, "{1906D8A5-7DEC-4DE3-A606-9E53BB3459E7}")
 
 Matrix3x4 ()=default
 Default constructor, which does not initialize the matrix.
 
 Matrix3x4 (const Matrix3x4 &rhs)=default
 
 Matrix3x4 (Simd::Vec4::FloatArgType row0, Simd::Vec4::FloatArgType row1, Simd::Vec4::FloatArgType row2)
 
void StoreToRowMajorFloat12 (float values[12]) const
 
void StoreToColumnMajorFloat12 (float values[12]) const
 
void StoreToColumnMajorFloat16 (float values[16]) const
 
float GetElement (int32_t row, int32_t col) const
 
void SetElement (int32_t row, int32_t col, const float value)
 
float operator() (int32_t row, int32_t col) const
 
Vector4 GetRow (int32_t row) const
 Gets the specified row.
 
Vector3 GetRowAsVector3 (int32_t row) const
 Gets the specified row as a Vector3.
 
void SetRow (int32_t row, float x, float y, float z, float w)
 Sets the specified row.
 
void SetRow (int32_t row, const Vector3 &v, float w)
 Sets the specified row.
 
void SetRow (int32_t row, const Vector4 &v)
 Sets the specified row.
 
void GetRows (Vector4 *row0, Vector4 *row1, Vector4 *row2) const
 Gets all rows of the matrix.
 
void SetRows (const Vector4 &row0, const Vector4 &row1, const Vector4 &row2)
 Sets all rows of the matrix.
 
Vector3 GetColumn (int32_t col) const
 Gets the specified column.
 
void SetColumn (int32_t col, float x, float y, float z)
 Sets the specified column.
 
void SetColumn (int32_t col, const Vector3 &v)
 Sets the specified column.
 
void GetColumns (Vector3 *col0, Vector3 *col1, Vector3 *col2, Vector3 *col3) const
 Gets all the columns of the matrix.
 
void SetColumns (const Vector3 &col0, const Vector3 &col1, const Vector3 &col2, const Vector3 &col3)
 Sets all the columns of the matrix.
 
Vector3 GetBasisX () const
 Gets the X basis vector of the matrix.
 
void SetBasisX (float x, float y, float z)
 Sets the X basis vector of the matrix.
 
void SetBasisX (const Vector3 &v)
 Sets the X basis vector of the matrix.
 
Vector3 GetBasisY () const
 Gets the Y basis vector of the matrix.
 
void SetBasisY (float x, float y, float z)
 Sets the Y basis vector of the matrix.
 
void SetBasisY (const Vector3 &v)
 Sets the Y basis vector of the matrix.
 
Vector3 GetBasisZ () const
 Gets the Z basis vector of the matrix.
 
void SetBasisZ (float x, float y, float z)
 Sets the Z basis vector of the matrix.
 
void SetBasisZ (const Vector3 &v)
 Sets the Z basis vector of the matrix.
 
Vector3 GetTranslation () const
 Gets the translation.
 
void SetTranslation (float x, float y, float z)
 Sets the translation.
 
void SetTranslation (const Vector3 &v)
 Sets the translation.
 
void GetBasisAndTranslation (Vector3 *basisX, Vector3 *basisY, Vector3 *basisZ, Vector3 *translation) const
 Gets the three basis vectors and the translation.
 
void SetBasisAndTranslation (const Vector3 &basisX, const Vector3 &basisY, const Vector3 &basisZ, const Vector3 &translation)
 Sets the three basis vectors and the translation.
 
Matrix3x4 operator- () const
 Operator for negating all matrix's elements.
 
Vector3 operator* (const Vector3 &rhs) const
 Operator for transforming a Vector3.
 
Vector4 operator* (const Vector4 &rhs) const
 Operator for transforming a Vector4.
 
Vector3 Multiply3x3 (const Vector3 &rhs) const
 Post-multiplies the matrix by a vector, using only the 3x3 part of the matrix.
 
Vector3 TransformVector (const Vector3 &rhs) const
 Post-multiplies the matrix by a vector, using only the 3x3 part of the matrix.
 
Vector3 TransformPoint (const Vector3 &rhs) const
 Post-multiplies the matrix by a point, using the rotation and translation part of the matrix.
 
Matrix3x4 GetTranspose () const
 Gets the result of transposing the 3x3 part of the matrix, setting the translation part to zero.
 
void Transpose ()
 Transposes the 3x3 part of the matrix, and sets the translation part to zero.
 
Matrix3x4 GetTranspose3x3 () const
 Gets the matrix obtained by transposing the 3x3 part of the matrix, leaving the translation untouched.
 
void Transpose3x3 ()
 Transposes the 3x3 part of the matrix, leaving the translation untouched.
 
Matrix3x4 GetInverseFull () const
 
void InvertFull ()
 
Matrix3x4 GetInverseFast () const
 Gets the inverse of the transformation represented by the matrix, assuming the 3x3 part is orthogonal.
 
void InvertFast ()
 Inverts the transformation represented by the matrix, assuming the 3x3 part is orthogonal.
 
Vector3 RetrieveScale () const
 Gets the scale part of the transformation (the length of the basis vectors).
 
Vector3 RetrieveScaleSq () const
 Gets the squared scale part of the transformation (the squared length of the basis vectors).
 
Vector3 ExtractScale ()
 Gets the scale part of the transformation as in RetrieveScale, and also removes this scaling from the matrix.
 
void MultiplyByScale (const Vector3 &scale)
 Multiplies the basis vectors of the matrix by the elements of the scale specified.
 
Matrix3x4 GetReciprocalScaled () const
 Returns a matrix with the reciprocal scale, keeping the same rotation and translation.
 
bool IsOrthogonal (float tolerance=Constants::Tolerance) const
 Tests if the 3x3 part of the matrix is orthogonal.
 
Matrix3x4 GetOrthogonalized () const
 Returns an orthogonal matrix based on this matrix.
 
void Orthogonalize ()
 Modifies the basis vectors of the matrix to be orthogonal and unit length.
 
bool IsClose (const Matrix3x4 &rhs, float tolerance=Constants::Tolerance) const
 Tests element-wise whether this matrix is close to another matrix, within the specified tolerance.
 
bool operator== (const Matrix3x4 &rhs) const
 Tests whether this matrix is identical to another matrix.
 
bool operator!= (const Matrix3x4 &rhs) const
 Tests whether this matrix is not identical to another matrix.
 
Vector3 GetEulerDegrees () const
 
Vector3 GetEulerRadians () const
 
void SetFromEulerDegrees (const Vector3 &eulerDegrees)
 
void SetFromEulerRadians (const Vector3 &eulerRadians)
 
void SetRotationPartFromQuaternion (const Quaternion &quaternion)
 Sets the 3x3 part of the matrix from a quaternion.
 
float GetDeterminant3x3 () const
 Calculates the determinant of the 3x3 part of the matrix.
 
bool IsFinite () const
 Checks whether the elements of the matrix are all finite.
 
const Simd::Vec4::FloatType * GetSimdValues () const
 
Simd::Vec4::FloatType * GetSimdValues ()
 
Matrix3x4 operator+ (const Matrix3x4 &rhs) const
 
Matrix3x4operator+= (const Matrix3x4 &rhs)
 
Matrix3x4 operator- (const Matrix3x4 &rhs) const
 
Matrix3x4operator-= (const Matrix3x4 &rhs)
 
Matrix3x4 operator* (const Matrix3x4 &rhs) const
 
Matrix3x4operator*= (const Matrix3x4 &rhs)
 
Matrix3x4 operator* (float multiplier) const
 
Matrix3x4operator*= (float multiplier)
 
Matrix3x4 operator/ (float divisor) const
 
Matrix3x4operator/= (float divisor)
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static Matrix3x4 CreateIdentity ()
 Creates an identity Matrix3x4.
 
static Matrix3x4 CreateZero ()
 Creates a Matrix3x4 with all values zero.
 
static Matrix3x4 CreateFromValue (float value)
 Constructs a matrix with all components set to the specified value.
 
static Matrix3x4 CreateFromRowMajorFloat12 (const float values[12])
 Constructs from an array of 12 floats stored in row-major order.
 
static Matrix3x4 CreateFromRows (const Vector4 &row0, const Vector4 &row1, const Vector4 &row2)
 Constructs from individual rows.
 
static Matrix3x4 CreateFromColumnMajorFloat12 (const float values[12])
 Constructs from an array of 12 floats stored in column-major order.
 
static Matrix3x4 CreateFromColumns (const Vector3 &col0, const Vector3 &col1, const Vector3 &col2, const Vector3 &col3)
 Constructs from individual columns.
 
static Matrix3x4 CreateFromColumnMajorFloat16 (const float values[16])
 
static Matrix3x4 CreateRotationX (float angle)
 Sets the matrix to be a rotation around the X-axis, specified in radians.
 
static Matrix3x4 CreateRotationY (float angle)
 Sets the matrix to be a rotation around the Y-axis, specified in radians.
 
static Matrix3x4 CreateRotationZ (float angle)
 Sets the matrix to be a rotation around the Z-axis, specified in radians.
 
static Matrix3x4 CreateFromQuaternion (const Quaternion &quaternion)
 Sets the matrix from a quaternion, with translation set to zero.
 
static Matrix3x4 CreateFromQuaternionAndTranslation (const Quaternion &quaternion, const Vector3 &translation)
 Sets the matrix from a quaternion and a translation.
 
static Matrix3x4 CreateFromMatrix3x3 (const Matrix3x3 &matrix3x3)
 Constructs from a Matrix3x3, with translation set to zero.
 
static Matrix3x4 CreateFromMatrix3x3AndTranslation (const Matrix3x3 &matrix3x3, const Vector3 &translation)
 Constructs from a Matrix3x3 and a translation.
 
static Matrix3x4 UnsafeCreateFromMatrix4x4 (const Matrix4x4 &matrix4x4)
 Constructs from a Matrix4x4.
 
static Matrix3x4 CreateFromTransform (const Transform &transform)
 Constructs from a Transform.
 
static Matrix3x4 CreateScale (const Vector3 &scale)
 Sets the matrix to be a scale matrix, with translation set to zero.
 
static Matrix3x4 CreateDiagonal (const Vector3 &diagonal)
 Sets the matrix to be a diagonal matrix, with translation set to zero.
 
static Matrix3x4 CreateTranslation (const Vector3 &translation)
 Sets the matrix to be a translation matrix, with 3x3 part set to the identity.
 
static Matrix3x4 CreateLookAt (const Vector3 &from, const Vector3 &to, Matrix3x4::Axis forwardAxis=Matrix3x4::Axis::YPositive)
 
static Matrix3x4 Identity ()
 Returns a reference to the identity Matrix3x4.
 

Static Public Attributes

static constexpr int32_t RowCount = 3
 
static constexpr int32_t ColCount = 4
 

Detailed Description

Stores a matrix with 3 rows and 4 columns. The 3x3 matrix formed of the first 3 columns may represent rotation, scale and/or shear, and the final column represents translation.

Member Function Documentation

◆ CreateFromColumnMajorFloat16()

AZ_MATH_INLINE Matrix3x4 AZ::Matrix3x4::CreateFromColumnMajorFloat16 ( const float  values[16])
static

Constructs from an array of 16 floats stored in column-major order. The 16 floats are treated as 4 columns of 4 values, but the 4th value of each column is ignored.

◆ CreateLookAt()

static Matrix3x4 AZ::Matrix3x4::CreateLookAt ( const Vector3 from,
const Vector3 to,
Matrix3x4::Axis  forwardAxis = Matrix3x4::Axis::YPositive 
)
static

Creates a "look at" matrix. Given a source position and target position, computes a transform at the source position that points toward the target along a chosen local-space axis.

Parameters
fromThe source position (world space).
toThe target position (world space).
forwardAxisThe local-space basis axis that should "look at" the target.
Returns
The resulting Matrix3x4 or the identity if the source and target coincide.

◆ GetElement()

AZ_MATH_INLINE float AZ::Matrix3x4::GetElement ( int32_t  row,
int32_t  col 
) const

Gets the element in the specified row and column. Accessing individual elements can be slower than working with entire rows.

◆ GetEulerDegrees()

AZ_MATH_INLINE Vector3 AZ::Matrix3x4::GetEulerDegrees ( ) const

Converts the 3x3 part of the matrix to corresponding Euler angles (Z, then Y, then X), in degrees.

Returns
Component-wise rotation angles in degrees.

◆ GetEulerRadians()

Vector3 AZ::Matrix3x4::GetEulerRadians ( ) const

Converts the 3x3 part of the matrix to corresponding Euler angles (Z, then Y, then X), in radians.

Returns
Component-wise rotation angles in radians.

◆ GetInverseFull()

Matrix3x4 AZ::Matrix3x4::GetInverseFull ( ) const

Gets the inverse of the transformation represented by the matrix. This function works for any matrix, even if they have scaling or skew. If the 3x3 part of the matrix is orthogonal then GetInverseFast is much faster.

◆ InvertFull()

AZ_MATH_INLINE void AZ::Matrix3x4::InvertFull ( )

Inverts the transformation represented by the matrix. This function works for any matrix, even if they have scaling or skew. If the 3x3 part of the matrix is orthogonal then InvertFast is much faster.

◆ operator()()

AZ_MATH_INLINE float AZ::Matrix3x4::operator() ( int32_t  row,
int32_t  col 
) const

Accesses the element in the specified row and column. Accessing individual elements can be slower than working with entire rows.

◆ operator*() [1/2]

AZ_MATH_INLINE Matrix3x4 AZ::Matrix3x4::operator* ( const Matrix3x4 rhs) const

Operator for matrix-matrix multiplication.

◆ operator*() [2/2]

AZ_MATH_INLINE Matrix3x4 AZ::Matrix3x4::operator* ( float  multiplier) const

Operator for multiplying all matrix's elements with a scalar

◆ operator+()

AZ_MATH_INLINE Matrix3x4 AZ::Matrix3x4::operator+ ( const Matrix3x4 rhs) const

Operator for matrix-matrix addition.

◆ operator-()

AZ_MATH_INLINE Matrix3x4 AZ::Matrix3x4::operator- ( const Matrix3x4 rhs) const

Operator for matrix-matrix subtraction.

◆ operator/()

AZ_MATH_INLINE Matrix3x4 AZ::Matrix3x4::operator/ ( float  divisor) const

Operator for dividing all matrix's elements with a scalar

◆ Reflect()

static void AZ::Matrix3x4::Reflect ( ReflectContext context)
static

AzCore Reflection.

Parameters
contextreflection context

◆ SetElement()

AZ_MATH_INLINE void AZ::Matrix3x4::SetElement ( int32_t  row,
int32_t  col,
const float  value 
)

Sets the element in the specified row and column. Accessing individual elements can be slower than working with entire rows.

◆ SetFromEulerDegrees()

AZ_MATH_INLINE void AZ::Matrix3x4::SetFromEulerDegrees ( const Vector3 eulerDegrees)

Sets the 3x3 part of the matrix from Euler Angles (rotation angles in Z, then Y, then X), in degrees. The translation is set to zero.

Parameters
eulerDegreesComponent-wise rotation angles in degrees.
Returns
A matrix calculated from the composition of rotations around Z, then Y, then X, with zero translation.

◆ SetFromEulerRadians()

void AZ::Matrix3x4::SetFromEulerRadians ( const Vector3 eulerRadians)

Sets the 3x3 part of the matrix from Euler Angles (rotation angles in Z, then Y, then X), in radians. The translation is set to zero.

Parameters
Vector3eulerRadians Component-wise rotation angles in radians.
Returns
A matrix calculated from the composition of rotations around Z, then Y, then X, with zero translation.

◆ StoreToColumnMajorFloat12()

AZ_MATH_INLINE void AZ::Matrix3x4::StoreToColumnMajorFloat12 ( float  values[12]) const

Stores the matrix into to an array of 12 floats. The floats need only be 4 byte aligned, 16 byte alignment is not required.

◆ StoreToColumnMajorFloat16()

AZ_MATH_INLINE void AZ::Matrix3x4::StoreToColumnMajorFloat16 ( float  values[16]) const

Stores the matrix into to an array of 16 floats. Because the matrix contains only 12 elements, there are 4 padding values in the array of 16 which may have arbitrary values written to them. The floats need only be 4 byte aligned, 16 byte alignment is not required.

◆ StoreToRowMajorFloat12()

AZ_MATH_INLINE void AZ::Matrix3x4::StoreToRowMajorFloat12 ( float  values[12]) const

Stores the matrix into to an array of 12 floats. The floats need only be 4 byte aligned, 16 byte alignment is not required.


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