Tizen Native API  6.0

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.
Matrixoperator= (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 Vector4GetTranslation () const
 Gets the translation.
const Vector3GetTranslation3 () 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:
3.0, DALi version 1.0.0

Constructor & Destructor Documentation

Constructor.

Zero initializes the matrix.

Since:
3.0, DALi version 1.0.0
Dali::Matrix::Matrix ( bool  initialize) [explicit]

Constructor.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]initializeTrue 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:
3.0, DALi version 1.0.0
Parameters:
[in]arrayPointer of 16 floats data
Dali::Matrix::Matrix ( const Quaternion rotation) [explicit]

Constructs a matrix from quaternion.

Since:
3.0, DALi version 1.0.0
Parameters:
rotationRotation as quaternion
Dali::Matrix::Matrix ( const Matrix matrix)

Copy constructor.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]matrixA 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:
3.0, 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)

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:
3.0, 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:
3.0, DALi version 1.0.0
Parameters:
[out]positionPosition to set
[out]rotationRotation to set - only valid if the transform matrix has not been skewed or sheared
[out]scaleScale to set - only valid if the transform matrix has not been skewed or sheared
Precondition:
This matrix must not contain skews or shears.

Gets the translation.

This assumes the matrix is a transform matrix.

Since:
3.0, DALi version 1.0.0
Returns:
The translation
Note:
inlined for performance reasons (generates less code than a function call)

Gets the x,y and z components of the translation as a Vector3.

This assumes the matrix is a transform matrix.

Since:
3.0, DALi version 1.0.0
Returns:
The translation
Note:
inlined for performance reasons (generates less code than a function call)

Returns the xAxis from a Transform matrix.

Since:
3.0, DALi version 1.0.0
Returns:
The x axis

Returns the yAxis from a Transform matrix.

Since:
3.0, DALi version 1.0.0
Returns:
The y axis

Returns the zAxis from a Transform matrix.

Since:
3.0, DALi version 1.0.0
Returns:
The z axis

Generic brute force Matrix Invert.

Using the Matrix invert function for the specific type of matrix you are dealing with is faster, more accurate.

Since:
3.0, DALi version 1.0.0
Returns:
True if successful
void Dali::Matrix::InvertTransform ( Matrix result) const

Inverts a transform Matrix.

Any Matrix representing only a rotation and/or translation can be inverted using this function. It is faster and more accurate then using Invert().

Since:
3.0, DALi version 1.0.0
Parameters:
[out]resultThe inverse of this matrix
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:
3.0, DALi version 1.0.0
Parameters:
[out]resultResult of the multiplication
[in]lhsMatrix, this can be same matrix as result
[in]rhsMatrix, this cannot be same matrix as result
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:
3.0, DALi version 1.0.0
Parameters:
[out]resultResult of the multiplication
[in]lhsMatrix, this can be same matrix as result
[in]rhsQuaternion
bool Dali::Matrix::operator!= ( const Matrix rhs) const

The inequality operator.

Utilizes appropriate machine epsilon values.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]rhsThe Matrix to compare this to
Returns:
true if the matrices are not equal.
Vector4 Dali::Matrix::operator* ( const Vector4 rhs) const

The multiplication operator.

Returned Vector = This Matrix * rhs

Since:
3.0, DALi version 1.0.0
Parameters:
[in]rhsThe Vector4 to multiply this by
Returns:
A Vector4 containing the result
Matrix& Dali::Matrix::operator= ( const Matrix matrix)

Assignment operator.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]matrixA 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:
3.0, DALi version 1.0.0
Parameters:
[in]rhsThe Matrix to compare this to
Returns:
true if the matrices are equal

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:
3.0, DALi version 1.0.0

Sets this matrix to be an identity matrix.

Since:
3.0, DALi version 1.0.0
void Dali::Matrix::SetIdentityAndScale ( const Vector3 scale)

Sets this matrix to be an identity matrix with scale.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]scaleScale 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:
3.0, DALi version 1.0.0
Parameters:
[in]scaleScale to apply
[in]rotationRotation to apply
[in]translationTranslation 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:
3.0, DALi version 1.0.0
Parameters:
[in]xAxisThe X axis of the basis
[in]yAxisThe Y axis of the basis
[in]zAxisThe Z axis of the basis
[in]translationTranslation 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:
3.0, DALi version 1.0.0
Parameters:
[in]scaleScale to apply
[in]rotationRotation to apply
[in]translationTranslation to apply
void Dali::Matrix::SetTranslation ( const Vector4 translation)

Sets the translation.

This assumes the matrix is a transform matrix.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]translationThe 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:
3.0, DALi version 1.0.0
Parameters:
[in]translationThe translation
void Dali::Matrix::SetXAxis ( const Vector3 axis)

Sets the x axis.

This assumes the matrix is a transform matrix.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]axisThe 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:
3.0, DALi version 1.0.0
Parameters:
[in]axisThe 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:
3.0, DALi version 1.0.0
Parameters:
[in]axisThe values to set the axis to

Swaps the rows to columns.

Since:
3.0, 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:
3.0, DALi version 1.0.0
Parameters:
[in]oThe output stream operator
[in]matrixThe matrix to print
Returns:
The output stream operator