Class Matrix
Definition
- Assembly:
- Tizen.NUI.dll
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.
public class Matrix : Disposable
- Inheritance
Constructors
View SourceMatrix()
The constructor initialized as zero.
Declaration
public Matrix()
Matrix(bool)
The constructor whether initialize matrix or not.
Declaration
public Matrix(bool initialize)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | initialize | True if we want to initialize values as zero. False if we just allocate and do not initalize value. |
Matrix(float[])
The constructor with continuous float array.
Declaration
public Matrix(float[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| float[] | array | Array of float value. |
Matrix(Matrix)
The constructor.
Declaration
public Matrix(Matrix matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | matrix | Matrix to create this matrix from |
Matrix(Rotation)
The constructor with Rotation to be rotation transform matrix.
Declaration
public Matrix(Rotation rotation)
Parameters
| Type | Name | Description |
|---|---|---|
| Rotation | rotation | Rotation information. |
Properties
View SourceIdentity
The matrix as identity
Declaration
public static Matrix Identity { get; }
Property Value
| Type | Description |
|---|---|
| Matrix |
this[uint]
Get/set the value of matrix by it's index.
Declaration
public float this[uint index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| uint | index | The index to get/set value. |
Property Value
| Type | Description |
|---|---|
| float |
Methods
View SourceEqualTo(Matrix)
Compares if rhs is equal to.
Declaration
public bool EqualTo(Matrix rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | rhs | The matrix to compare. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the two matrixes are equal, otherwise false. |
GetHashCode()
Gets the hash code of this Matrix.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | The Hash Code. |
GetTransformComponents(Vector3, Rotation, Vector3)
Gets the position, scale and rotation components from the given transform matrix.
Declaration
public void GetTransformComponents(Vector3 position, Rotation rotation, Vector3 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | Position to set. |
| Rotation | rotation | Rotation to set - only valid if the transform matrix has not been skewed or sheared |
| Vector3 | scale | Scale to set - only valid if the transform matrix has not been skewed or sheared. |
GetTranslation()
Gets the translate from a Transform matrix.
This assumes the matrix is a transform matrix.
Declaration
public Vector4 GetTranslation()
Returns
| Type | Description |
|---|---|
| Vector4 | The Translation. |
GetTranslation3()
Gets the x, y, and z components of translate from a Transform matrix.
This assumes the matrix is a transform matrix.
Declaration
public Vector3 GetTranslation3()
Returns
| Type | Description |
|---|---|
| Vector3 | The Translation. |
GetXAxis()
Returns the X Axis from a Transform matrix.
Declaration
public Vector3 GetXAxis()
Returns
| Type | Description |
|---|---|
| Vector3 | The X axis. |
GetYAxis()
Returns the Y Axis from a Transform matrix.
Declaration
public Vector3 GetYAxis()
Returns
| Type | Description |
|---|---|
| Vector3 | The Y axis. |
GetZAxis()
Returns the Z Axis from a Transform matrix.
Declaration
public Vector3 GetZAxis()
Returns
| Type | Description |
|---|---|
| Vector3 | The Z axis. |
Invert()
Generic brute force matrix invert.
Declaration
public bool Invert()
Returns
| Type | Description |
|---|---|
| bool | True if successful. |
InvertTransform(Matrix)
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().
Declaration
public void InvertTransform(Matrix result)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | result | The inverse of this Matrix. |
Multiply(Matrix, Matrix, Matrix)
Function to multiply two matrices and store the result onto third.
Use this method in time critical path as it does not require temporaries.
Declaration
public static void Multiply(Matrix result, Matrix lhs, Matrix rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | result | Result of the multiplication. |
| Matrix | lhs | The left-hand-side Matrix. this can be same matrix as result. |
| Matrix | rhs | The right-hand-side Matrix. this cannot be same matrix as result. |
Multiply(Matrix, Matrix, Rotation)
Function to multiply a matrix and rotataion and store the result onto third.
Use this method in time critical path as it does not require temporaries.
Declaration
public static void Multiply(Matrix result, Matrix lhs, Rotation rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | result | Result of the multiplication. |
| Matrix | lhs | The left-hand-side Matrix. this can be same matrix as result. |
| Rotation | rhs | The right-hand-side Rotation. |
Multiply(Matrix)
Multiply the Matrix and Matrix.
Declaration
public Matrix Multiply(Matrix rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | rhs | The right-hand-side Matrix. |
Returns
| Type | Description |
|---|---|
| Matrix | The matrix multiply as this * rhs. |
Multiply(Vector4)
Multiply the Matrix and Vector4.
Declaration
public Vector4 Multiply(Vector4 rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector4 | rhs | The right-hand-side Vector4. |
Returns
| Type | Description |
|---|---|
| Vector4 | The vector multiply as this * rhs. |
MultiplyAssign(Matrix)
Multiply the Matrix and Matrix. Result will be stored into this Matrix.
Declaration
public void MultiplyAssign(Matrix rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | rhs | The right-hand-side Matrix. |
NotEqualTo(Matrix)
Compares if rhs is not equal to.
Declaration
public bool NotEqualTo(Matrix rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | rhs | The matrix to compare. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the two matrixes are not equal, otherwise false. |
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 assumes the matrix is a transform matrix.
Declaration
public void OrthoNormalize()
ReleaseSwigCPtr(HandleRef)
Declaration
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Runtime.InteropServices.HandleRef | swigCPtr |
Overrides
View SourceSetIdentity()
Make matrix as identity.
Declaration
public void SetIdentity()
SetIdentityAndScale(Vector3)
Make matrix as identity and multiply scale.
Declaration
public void SetIdentityAndScale(Vector3 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | scale | The scale value to be multiplied into identity Matrix. |
SetInverseTransformComponents(Vector3, Rotation, Vector3)
Sets this matrix to contain the inverse of the position, scale and rotation components.
Performs scale, rotation, then translation
Declaration
public void SetInverseTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | scale | Scale to apply. |
| Rotation | rotation | Rotation to apply. |
| Vector3 | translation | Translation to apply. |
SetInverseTransformComponents(Vector3, Vector3, Vector3, Vector3)
Sets this matrix to contain the inverse of the orthonormal basis and position components.
Performs scale, rotation, then translation
Declaration
public void SetInverseTransformComponents(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 translation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | xAxis | The X axis of the basis. |
| Vector3 | yAxis | The Y axis of the basis. |
| Vector3 | zAxis | The Z axis of the basis. |
| Vector3 | translation | Translation to apply. |
SetTransformComponents(Vector3, Rotation, Vector3)
Sets this matrix to contain the position, scale and rotation components.
Performs scale, rotation, then translation
Declaration
public void SetTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | scale | Scale to apply. |
| Rotation | rotation | Rotation to apply. |
| Vector3 | translation | Translation to apply. |
SetTranslation(Vector3)
Sets the translate to a Transform matrix.
This assumes the matrix is a transform matrix.
Declaration
public void SetTranslation(Vector3 translation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | translation | The translation. |
SetTranslation(Vector4)
Sets the translate to a Transform matrix.
This assumes the matrix is a transform matrix.
Declaration
public void SetTranslation(Vector4 translation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector4 | translation | The translation. |
SetValueAtIndex(uint, float)
Set the value at matrix by it's index.
Declaration
public void SetValueAtIndex(uint index, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | index | The index to set value. |
| float | value | The value to set. |
SetValueAtIndex(uint, uint, float)
Set the value at matrix by it's row index and column index.
Declaration
public void SetValueAtIndex(uint indexRow, uint indexColumn, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | indexRow | The row index to set value. |
| uint | indexColumn | The column index to set value. |
| float | value | The value to set. |
SetXAxis(Vector3)
Sets the X Axis to a Transform matrix.
This assumes the matrix is a transform matrix.
Declaration
public void SetXAxis(Vector3 axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | axis | The X axis. |
SetYAxis(Vector3)
Sets the Y Axis to a Transform matrix.
This assumes the matrix is a transform matrix.
Declaration
public void SetYAxis(Vector3 axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | axis | The Y axis. |
SetZAxis(Vector3)
Sets the Z Axis to a Transform matrix.
This assumes the matrix is a transform matrix.
Declaration
public void SetZAxis(Vector3 axis)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | axis | The Z axis. |
Transpose()
Swaps the rows to columns.
Declaration
public void Transpose()
ValueOfIndex(uint, uint)
Get the value of matrix by it's row index and column index.
Declaration
public float ValueOfIndex(uint indexRow, uint indexColumn)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | indexRow | The row index to get value. |
| uint | indexColumn | The column index to get value. |
Returns
| Type | Description |
|---|---|
| float | A value of index |
ValueOfIndex(uint)
Get the value of matrix by it's index.
Declaration
public float ValueOfIndex(uint index)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | index | The index to get value. |
Returns
| Type | Description |
|---|---|
| float | A value of index |
Operators
View Sourceoperator *(Matrix, Matrix)
Multiply Matrix and Matrix.
Declaration
public static Matrix operator *(Matrix lhs, Matrix rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | lhs | The left-hand-side Matrix. |
| Matrix | rhs | The right-hand-side Matrix. |
Returns
| Type | Description |
|---|---|
| Matrix | The Matrix multiply as lhs * rhs. |
operator *(Matrix, Vector4)
Multiply Matrix and Vector4.
Declaration
public static Vector4 operator *(Matrix lhs, Vector4 rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | lhs | The left-hand-side Matrix. |
| Vector4 | rhs | The right-hand-side Vector4. |
Returns
| Type | Description |
|---|---|
| Vector4 | The vector multiply as lhs * rhs. |
operator *(Rotation, Matrix)
Multiply Rotation matrix and Matrix.
Declaration
public static Matrix operator *(Rotation lhs, Matrix rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Rotation | lhs | The left-hand-side Rotation. |
| Matrix | rhs | The right-hand-side Matrix. |
Returns
| Type | Description |
|---|---|
| Matrix | The Matrix multiply as lhs * rhs. |