Class Matrix

Definition

Namespace:
Tizen.NUI
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):

Copy
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.

C#
Copy
public class Matrix : Disposable
Inheritance

Constructors

View Source

Matrix()

The constructor initialized as zero.

Declaration
C#
Copy
public Matrix()
View Source

Matrix(Boolean)

The constructor whether initialize matrix or not.

Declaration
C#
Copy
public Matrix(bool initialize)
Parameters
Type Name Description
Boolean initialize

True if we want to initialize values as zero. False if we just allocate and do not initalize value.

View Source

Matrix(Single[])

The constructor with continuous float array.

Declaration
C#
Copy
public Matrix(float[] array)
Parameters
Type Name Description
Single[] array

Array of float value.

View Source

Matrix(Matrix)

The constructor.

Declaration
C#
Copy
public Matrix(Matrix matrix)
Parameters
Type Name Description
Matrix matrix

Matrix to create this matrix from

View Source

Matrix(Rotation)

The constructor with Rotation to be rotation transform matrix.

Declaration
C#
Copy
public Matrix(Rotation rotation)
Parameters
Type Name Description
Rotation rotation

Rotation information.

Properties

View Source

Identity

The matrix as identity

Declaration
C#
Copy
public static Matrix Identity { get; }
Property Value
Type Description
Matrix
View Source

Item[UInt32]

Get/set the value of matrix by it's index.

Declaration
C#
Copy
public float this[uint index] { get; set; }
Parameters
Type Name Description
UInt32 index

The index to get/set value.

Property Value
Type Description
Single

Methods

View Source

EqualTo(Matrix)

Compares if rhs is equal to.

Declaration
C#
Copy
public bool EqualTo(Matrix rhs)
Parameters
Type Name Description
Matrix rhs

The matrix to compare.

Returns
Type Description
Boolean

Returns true if the two matrixes are equal, otherwise false.

View Source

GetHashCode()

Gets the hash code of this Matrix.

Declaration
C#
Copy
public override int GetHashCode()
Returns
Type Description
Int32

The Hash Code.

View Source

GetTransformComponents(Vector3, Rotation, Vector3)

Gets the position, scale and rotation components from the given transform matrix.

Declaration
C#
Copy
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.

View Source

GetTranslation()

Gets the translate from a Transform matrix.
This assumes the matrix is a transform matrix.

Declaration
C#
Copy
public Vector4 GetTranslation()
Returns
Type Description
Vector4

The Translation.

View Source

GetTranslation3()

Gets the x, y, and z components of translate from a Transform matrix.
This assumes the matrix is a transform matrix.

Declaration
C#
Copy
public Vector3 GetTranslation3()
Returns
Type Description
Vector3

The Translation.

View Source

GetXAxis()

Returns the X Axis from a Transform matrix.

Declaration
C#
Copy
public Vector3 GetXAxis()
Returns
Type Description
Vector3

The X axis.

View Source

GetYAxis()

Returns the Y Axis from a Transform matrix.

Declaration
C#
Copy
public Vector3 GetYAxis()
Returns
Type Description
Vector3

The Y axis.

View Source

GetZAxis()

Returns the Z Axis from a Transform matrix.

Declaration
C#
Copy
public Vector3 GetZAxis()
Returns
Type Description
Vector3

The Z axis.

View Source

Invert()

Generic brute force matrix invert.

Declaration
C#
Copy
public bool Invert()
Returns
Type Description
Boolean

True if successful.

View Source

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
C#
Copy
public void InvertTransform(Matrix result)
Parameters
Type Name Description
Matrix result

The inverse of this Matrix.

View Source

Multiply(Matrix)

Multiply the Matrix and Matrix.

Declaration
C#
Copy
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.

View Source

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
C#
Copy
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.

View Source

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
C#
Copy
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.

View Source

Multiply(Vector4)

Multiply the Matrix and Vector4.

Declaration
C#
Copy
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.

View Source

MultiplyAssign(Matrix)

Multiply the Matrix and Matrix. Result will be stored into this Matrix.

Declaration
C#
Copy
public void MultiplyAssign(Matrix rhs)
Parameters
Type Name Description
Matrix rhs

The right-hand-side Matrix.

View Source

NotEqualTo(Matrix)

Compares if rhs is not equal to.

Declaration
C#
Copy
public bool NotEqualTo(Matrix rhs)
Parameters
Type Name Description
Matrix rhs

The matrix to compare.

Returns
Type Description
Boolean

Returns true if the two matrixes are not equal, otherwise false.

View Source

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
C#
Copy
public void OrthoNormalize()
View Source

ReleaseSwigCPtr(Runtime.InteropServices.HandleRef)

Declaration
C#
Copy
protected override void ReleaseSwigCPtr(Runtime.InteropServices.HandleRef swigCPtr)
Parameters
Type Name Description
Tizen.System.Runtime.InteropServices.HandleRef swigCPtr
Overrides
View Source

SetIdentity()

Make matrix as identity.

Declaration
C#
Copy
public void SetIdentity()
View Source

SetIdentityAndScale(Vector3)

Make matrix as identity and multiply scale.

Declaration
C#
Copy
public void SetIdentityAndScale(Vector3 scale)
Parameters
Type Name Description
Vector3 scale

The scale value to be multiplied into identity Matrix.

View Source

SetInverseTransformComponents(Vector3, Rotation, Vector3)

Sets this matrix to contain the inverse of the position, scale and rotation components.
Performs scale, rotation, then translation

Declaration
C#
Copy
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.

View Source

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
C#
Copy
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.

View Source

SetTransformComponents(Vector3, Rotation, Vector3)

Sets this matrix to contain the position, scale and rotation components.
Performs scale, rotation, then translation

Declaration
C#
Copy
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.

View Source

SetTranslation(Vector3)

Sets the translate to a Transform matrix.
This assumes the matrix is a transform matrix.

Declaration
C#
Copy
public void SetTranslation(Vector3 translation)
Parameters
Type Name Description
Vector3 translation

The translation.

View Source

SetTranslation(Vector4)

Sets the translate to a Transform matrix.
This assumes the matrix is a transform matrix.

Declaration
C#
Copy
public void SetTranslation(Vector4 translation)
Parameters
Type Name Description
Vector4 translation

The translation.

View Source

SetValueAtIndex(UInt32, Single)

Set the value at matrix by it's index.

Declaration
C#
Copy
public void SetValueAtIndex(uint index, float value)
Parameters
Type Name Description
UInt32 index

The index to set value.

Single value

The value to set.

View Source

SetValueAtIndex(UInt32, UInt32, Single)

Set the value at matrix by it's row index and column index.

Declaration
C#
Copy
public void SetValueAtIndex(uint indexRow, uint indexColumn, float value)
Parameters
Type Name Description
UInt32 indexRow

The row index to set value.

UInt32 indexColumn

The column index to set value.

Single value

The value to set.

View Source

SetXAxis(Vector3)

Sets the X Axis to a Transform matrix.
This assumes the matrix is a transform matrix.

Declaration
C#
Copy
public void SetXAxis(Vector3 axis)
Parameters
Type Name Description
Vector3 axis

The X axis.

View Source

SetYAxis(Vector3)

Sets the Y Axis to a Transform matrix.
This assumes the matrix is a transform matrix.

Declaration
C#
Copy
public void SetYAxis(Vector3 axis)
Parameters
Type Name Description
Vector3 axis

The Y axis.

View Source

SetZAxis(Vector3)

Sets the Z Axis to a Transform matrix.
This assumes the matrix is a transform matrix.

Declaration
C#
Copy
public void SetZAxis(Vector3 axis)
Parameters
Type Name Description
Vector3 axis

The Z axis.

View Source

Transpose()

Swaps the rows to columns.

Declaration
C#
Copy
public void Transpose()
View Source

ValueOfIndex(UInt32)

Get the value of matrix by it's index.

Declaration
C#
Copy
public float ValueOfIndex(uint index)
Parameters
Type Name Description
UInt32 index

The index to get value.

Returns
Type Description
Single

A value of index

View Source

ValueOfIndex(UInt32, UInt32)

Get the value of matrix by it's row index and column index.

Declaration
C#
Copy
public float ValueOfIndex(uint indexRow, uint indexColumn)
Parameters
Type Name Description
UInt32 indexRow

The row index to get value.

UInt32 indexColumn

The column index to get value.

Returns
Type Description
Single

A value of index

Operators

View Source

Multiply(Matrix, Matrix)

Multiply Matrix and Matrix.

Declaration
C#
Copy
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.

View Source

Multiply(Matrix, Vector4)

Multiply Matrix and Vector4.

Declaration
C#
Copy
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.

View Source

Multiply(Rotation, Matrix)

Multiply Rotation matrix and Matrix.

Declaration
C#
Copy
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.

Extension Methods