Tizen(Headed) Native API
6.5
|
The Matrix class represents transformations and projections. More...
Public Member Functions | |
Matrix () | |
Constructor. | |
Matrix (bool initialize) | |
Constructor. | |
Matrix (const float *array) | |
Constructor. | |
Matrix (const Quaternion &rotation) | |
Constructs a matrix from quaternion. | |
Matrix (const Matrix &matrix) | |
Copy constructor. | |
Matrix & | operator= (const Matrix &matrix) |
Assignment operator. | |
void | SetIdentity () |
Sets this matrix to be an identity matrix. | |
void | SetIdentityAndScale (const Vector3 &scale) |
Sets this matrix to be an identity matrix with scale. | |
void | InvertTransform (Matrix &result) const |
Inverts a transform Matrix. | |
bool | Invert () |
Generic brute force Matrix Invert. | |
void | Transpose () |
Swaps the rows to columns. | |
Vector3 | GetXAxis () const |
Returns the xAxis from a Transform matrix. | |
Vector3 | GetYAxis () const |
Returns the yAxis from a Transform matrix. | |
Vector3 | GetZAxis () const |
Returns the zAxis from a Transform matrix. | |
void | SetXAxis (const Vector3 &axis) |
Sets the x axis. | |
void | SetYAxis (const Vector3 &axis) |
Sets the y axis. | |
void | SetZAxis (const Vector3 &axis) |
Sets the z axis. | |
const Vector4 & | GetTranslation () const |
Gets the translation. | |
const Vector3 & | GetTranslation3 () const |
Gets the x,y and z components of the translation as a Vector3. | |
void | SetTranslation (const Vector4 &translation) |
Sets the translation. | |
void | SetTranslation (const Vector3 &translation) |
Sets the x,y and z components of the translation from a Vector3. | |
void | OrthoNormalize () |
Makes the axes of the matrix orthogonal to each other and of unit length. | |
const float * | AsFloat () const |
Returns the contents of the matrix as an array of 16 floats. | |
float * | AsFloat () |
Returns the contents of the matrix as an array of 16 floats. | |
Vector4 | operator* (const Vector4 &rhs) const |
The multiplication operator. | |
bool | operator== (const Matrix &rhs) const |
The equality operator. | |
bool | operator!= (const Matrix &rhs) const |
The inequality operator. | |
void | SetTransformComponents (const Vector3 &scale, const Quaternion &rotation, const Vector3 &translation) |
Sets this matrix to contain the position, scale and rotation components. | |
void | SetInverseTransformComponents (const Vector3 &scale, const Quaternion &rotation, const Vector3 &translation) |
Sets this matrix to contain the inverse of the position, scale and rotation components. | |
void | SetInverseTransformComponents (const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis, const Vector3 &translation) |
Sets this matrix to contain the inverse of the orthonormal basis and position components. | |
void | GetTransformComponents (Vector3 &position, Quaternion &rotation, Vector3 &scale) const |
Gets the position, scale and rotation components from the given transform matrix. | |
Static Public Member Functions | |
static void | Multiply (Matrix &result, const Matrix &lhs, const Matrix &rhs) |
Function to multiply two matrices and store the result onto third. | |
static void | Multiply (Matrix &result, const Matrix &lhs, const Quaternion &rhs) |
Function to multiply a matrix and quaternion and store the result onto third. | |
Static Public Attributes | |
static const Matrix | IDENTITY |
The identity matrix. | |
Friends | |
DALI_CORE_API std::ostream & | operator<< (std::ostream &o, const Matrix &matrix) |
Prints a matrix. |
Detailed Description
The Matrix class represents transformations and projections.
The matrix is stored as a flat array and is Column Major, i.e. the storage order is as follows (numbers represent indices of array):
0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15
Each axis is contiguous in memory, so the x-axis corresponds to elements 0, 1, 2 and 3, the y-axis corresponds to elements 4, 5, 6, 7, the z-axis corresponds to elements 12, 13, 14 and 15, and the translation vector corresponds to elements 12, 13 and 14.
- Since:
- 2.4, DALi version 1.0.0
Constructor & Destructor Documentation
Constructor.
Zero initializes the matrix.
- Since:
- 2.4, DALi version 1.0.0
Dali::Matrix::Matrix | ( | bool | initialize | ) | [explicit] |
Constructor.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] initialize True for initialization by zero or otherwise
Dali::Matrix::Matrix | ( | const float * | array | ) | [explicit] |
Constructor.
The matrix is initialized with the contents of 'array' which must contain 16 floats. The order of the values for a transform matrix is:
[ xAxis.x, xAxis.y, xAxis.z, 0.0f, yAxis.x, yAxis.y, yAxis.z, 0.0f, zAxis.x, zAxis.y, zAxis.z, 0.0f, trans.x, trans.y, trans.z, 1.0f ]
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] array Pointer of 16 floats data
Dali::Matrix::Matrix | ( | const Quaternion & | rotation | ) | [explicit] |
Constructs a matrix from quaternion.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
rotation Rotation as quaternion
Dali::Matrix::Matrix | ( | const Matrix & | matrix | ) |
Copy constructor.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] matrix A reference to the copied matrix
Member Function Documentation
const float* Dali::Matrix::AsFloat | ( | ) | const |
Returns the contents of the matrix as an array of 16 floats.
The order of the values for a transform matrix is:
[ xAxis.x, xAxis.y, xAxis.z, 0.0f, yAxis.x, yAxis.y, yAxis.z, 0.0f, zAxis.x, zAxis.y, zAxis.z, 0.0f, trans.x, trans.y, trans.z, 1.0f ]
- Since:
- 2.4, DALi version 1.0.0
- Returns:
- The matrix contents as an array of 16 floats
- Note:
- inlined for performance reasons (generates less code than a function call)
float* Dali::Matrix::AsFloat | ( | ) |
Returns the contents of the matrix as an array of 16 floats.
The order of the values for a transform matrix is:
[ xAxis.x, xAxis.y, xAxis.z, 0.0f, yAxis.x, yAxis.y, yAxis.z, 0.0f, zAxis.x, zAxis.y, zAxis.z, 0.0f, trans.x, trans.y, trans.z, 1.0f ]
- Since:
- 2.4, DALi version 1.0.0
- Returns:
- The matrix contents as an array of 16 floats
- Note:
- inlined for performance reasons (generates less code than a function call)
void Dali::Matrix::GetTransformComponents | ( | Vector3 & | position, |
Quaternion & | rotation, | ||
Vector3 & | scale | ||
) | const |
Gets the position, scale and rotation components from the given transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[out] position Position to set [out] rotation Rotation to set - only valid if the transform matrix has not been skewed or sheared [out] scale Scale to set - only valid if the transform matrix has not been skewed or sheared
- Precondition:
- This matrix must not contain skews or shears.
const Vector4& Dali::Matrix::GetTranslation | ( | ) | const |
Gets the translation.
This assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Returns:
- The translation
- Note:
- inlined for performance reasons (generates less code than a function call)
const Vector3& Dali::Matrix::GetTranslation3 | ( | ) | const |
Gets the x,y and z components of the translation as a Vector3.
This assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Returns:
- The translation
- Note:
- inlined for performance reasons (generates less code than a function call)
Vector3 Dali::Matrix::GetXAxis | ( | ) | const |
Returns the xAxis from a Transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Returns:
- The x axis
Vector3 Dali::Matrix::GetYAxis | ( | ) | const |
Returns the yAxis from a Transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Returns:
- The y axis
Vector3 Dali::Matrix::GetZAxis | ( | ) | const |
Returns the zAxis from a Transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Returns:
- The z axis
bool Dali::Matrix::Invert | ( | ) |
void Dali::Matrix::InvertTransform | ( | Matrix & | result | ) | const |
static void Dali::Matrix::Multiply | ( | Matrix & | result, |
const Matrix & | lhs, | ||
const Matrix & | rhs | ||
) | [static] |
Function to multiply two matrices and store the result onto third.
Use this method in time critical path as it does not require temporaries.
result = rhs * lhs
- Since:
- 2.4, DALi version 1.0.0
static void Dali::Matrix::Multiply | ( | Matrix & | result, |
const Matrix & | lhs, | ||
const Quaternion & | rhs | ||
) | [static] |
Function to multiply a matrix and quaternion and store the result onto third.
Use this method in time critical path as it does not require temporaries.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[out] result Result of the multiplication [in] lhs Matrix, this can be same matrix as result [in] rhs Quaternion
bool Dali::Matrix::operator!= | ( | const Matrix & | rhs | ) | const |
The inequality operator.
Utilizes appropriate machine epsilon values.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] rhs The Matrix to compare this to
- Returns:
- true if the matrices are not equal.
Assignment operator.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] matrix A reference to the copied matrix
- Returns:
- A reference to this
bool Dali::Matrix::operator== | ( | const Matrix & | rhs | ) | const |
The equality operator.
Utilizes appropriate machine epsilon values.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] rhs The Matrix to compare this to
- Returns:
- true if the matrices are equal
void Dali::Matrix::OrthoNormalize | ( | ) |
Makes the axes of the matrix orthogonal to each other and of unit length.
This function is used to correct floating point errors which would otherwise accumulate as operations are applied to the matrix. This function assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
void Dali::Matrix::SetIdentity | ( | ) |
Sets this matrix to be an identity matrix.
- Since:
- 2.4, DALi version 1.0.0
void Dali::Matrix::SetIdentityAndScale | ( | const Vector3 & | scale | ) |
Sets this matrix to be an identity matrix with scale.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] scale Scale to set on top of identity matrix
void Dali::Matrix::SetInverseTransformComponents | ( | const Vector3 & | scale, |
const Quaternion & | rotation, | ||
const Vector3 & | translation | ||
) |
Sets this matrix to contain the inverse of the position, scale and rotation components.
Performs translation, then rotation, then scale.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] scale Scale to apply [in] rotation Rotation to apply [in] translation Translation to apply
void Dali::Matrix::SetInverseTransformComponents | ( | const Vector3 & | xAxis, |
const Vector3 & | yAxis, | ||
const Vector3 & | zAxis, | ||
const Vector3 & | translation | ||
) |
Sets this matrix to contain the inverse of the orthonormal basis and position components.
Performs translation, then rotation.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] xAxis The X axis of the basis [in] yAxis The Y axis of the basis [in] zAxis The Z axis of the basis [in] translation Translation to apply
void Dali::Matrix::SetTransformComponents | ( | const Vector3 & | scale, |
const Quaternion & | rotation, | ||
const Vector3 & | translation | ||
) |
Sets this matrix to contain the position, scale and rotation components.
Performs scale, rotation, then translation
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] scale Scale to apply [in] rotation Rotation to apply [in] translation Translation to apply
void Dali::Matrix::SetTranslation | ( | const Vector4 & | translation | ) |
Sets the translation.
This assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] translation The translation
void Dali::Matrix::SetTranslation | ( | const Vector3 & | translation | ) |
Sets the x,y and z components of the translation from a Vector3.
This assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] translation The translation
void Dali::Matrix::SetXAxis | ( | const Vector3 & | axis | ) |
Sets the x axis.
This assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] axis The values to set the axis to
void Dali::Matrix::SetYAxis | ( | const Vector3 & | axis | ) |
Sets the y axis.
This assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] axis The values to set the axis to
void Dali::Matrix::SetZAxis | ( | const Vector3 & | axis | ) |
Sets the z axis.
This assumes the matrix is a transform matrix.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] axis The values to set the axis to
void Dali::Matrix::Transpose | ( | ) |
Swaps the rows to columns.
- Since:
- 2.4, DALi version 1.0.0
Friends And Related Function Documentation
DALI_CORE_API std::ostream& operator<< | ( | std::ostream & | o, |
const Matrix & | matrix | ||
) | [friend] |
Prints a matrix.
It is printed in memory order.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] o The output stream operator [in] matrix The matrix to print
- Returns:
- The output stream operator