Tizen Native API
|
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 |
Invert 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 | |
std::ostream & | operator<< (std::ostream &o, const Matrix &matrix) |
Print a matrix. |
Detailed Description
The Matrix class represents transformations and projections.
It is agnostic w.r.t. row/column major notation - it operates on a flat array. Each axis is contiguous in memory, so the x axis corresponds to elements 0, 1, 2 and 3, the y axis dorresponds to elements 4, 5, 6, 7, etc.
- Since :
- 2.4
Constructor & Destructor Documentation
Constructor.
Zero initialises the matrix
- Since :
- 2.4
Dali::Matrix::Matrix | ( | bool | initialize | ) | [explicit] |
Constructor.
- Since :
- 2.4
- Parameters:
-
i] initialize True for initialization by zero or otherwise
Dali::Matrix::Matrix | ( | const float * | array | ) | [explicit] |
Constructor.
The matrix is initialised 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
- Parameters:
-
[in] array Pointer of 16 floats data
Dali::Matrix::Matrix | ( | const Quaternion & | rotation | ) | [explicit] |
Constructs a matrix from quaternion.
- Since :
- 2.4
- Parameters:
-
rotation Rotation as quaternion
Dali::Matrix::Matrix | ( | const Matrix & | matrix | ) |
Copy constructor.
- Since :
- 2.4
- 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
- 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
- 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
- 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
- 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
- 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
- Returns:
- The x axis
Vector3 Dali::Matrix::GetYAxis | ( | ) | const |
Returns the yAxis from a Transform matrix.
- Since :
- 2.4
- Returns:
- The y axis
Vector3 Dali::Matrix::GetZAxis | ( | ) | const |
Returns the zAxis from a Transform matrix.
- Since :
- 2.4
- 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
- Since :
- 2.4
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
- 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.
Utilises appropriate machine epsilon values.
- Since :
- 2.4
- Parameters:
-
[in] rhs The Matrix to compare this to
- Returns:
- True if the matrices are not equal.
The multiplication operator.
- Since :
- 2.4
- Parameters:
-
[in] rhs The Matrix to multiply this by
- Returns:
- A matrix containing the result
Assignment operator.
- Since :
- 2.4
- 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.
Utilises appropriate machine epsilon values.
- Since :
- 2.4
- 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
void Dali::Matrix::SetIdentity | ( | ) |
Sets this matrix to be an identity matrix.
- Since :
- 2.4
void Dali::Matrix::SetIdentityAndScale | ( | const Vector3 & | scale | ) |
Sets this matrix to be an identity matrix with scale.
- Since :
- 2.4
- Parameters:
-
i] 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- Parameters:
-
[in] axis The values to set the axis to
void Dali::Matrix::Transpose | ( | ) |
Swaps the rows to columns.
- Since :
- 2.4
Friends And Related Function Documentation
std::ostream& operator<< | ( | std::ostream & | o, |
const Matrix & | matrix | ||
) | [friend] |
Print a matrix.
It is printed in memory order, i.e. each printed row is contiguous in memory.
- Since :
- 2.4
- Parameters:
-
[in] o The output stream operator. [in] matrix The matrix to print.
- Returns:
- The output stream operator.