TriLib  1.9.0
TriLib Unity Package
TriLib.MatrixExtensions Class Reference

Represents a series of UnityEngine.Matrix4x4 extension methods. More...

Static Public Member Functions

static Quaternion ExtractRotation (this Matrix4x4 matrix)
 Extracts the rotation from a UnityEngine.Matrix4x4. More...
 
static Vector3 ExtractPosition (this Matrix4x4 matrix)
 Extracts the Position from a UnityEngine.Matrix4x4. More...
 
static Vector3 ExtractScale (this Matrix4x4 matrix)
 Extracts the scale from a UnityEngine.Matrix4x4. More...
 

Detailed Description

Represents a series of UnityEngine.Matrix4x4 extension methods.

Member Function Documentation

◆ ExtractPosition()

static Vector3 TriLib.MatrixExtensions.ExtractPosition ( this Matrix4x4  matrix)
static

Extracts the Position from a UnityEngine.Matrix4x4.

Parameters
matrixUnityEngine.Matrix4x4 to extract from.
Returns
Extracted position UnityEngine.Vector3.
//Creates a Matrix4x4 that moves 100 units forward in World Space, then rotate 90 units on y-Axis in Local Space
var myMatrix = Matrix4x4.TRS(new Vector3(0f, 0f, 100f), Quaternion.Euler(0f, 90f, 0f), Vector3.one);
//Assigns the position contained in the "myMatrix" to "myGameObject"
myGameObject.transform.position = myMatrix.ExtractRotation();

◆ ExtractRotation()

static Quaternion TriLib.MatrixExtensions.ExtractRotation ( this Matrix4x4  matrix)
static

Extracts the rotation from a UnityEngine.Matrix4x4.

Parameters
matrixUnityEngine.Matrix4x4 to extract from.
Returns
Extracted rotation UnityEngine.Quaternion.
//Creates a Matrix4x4 that moves 100 units forward in World Space, then rotate 90 units on y-Axis in Local Space
var myMatrix = Matrix4x4.TRS(new Vector3(0f, 0f, 100f), Quaternion.Euler(0f, 90f, 0f), Vector3.one);
//Assigns the rotation contained in the "myMatrix" to "myGameObject"
myGameObject.transform.rotation = myMatrix.ExtractRotation();

◆ ExtractScale()

static Vector3 TriLib.MatrixExtensions.ExtractScale ( this Matrix4x4  matrix)
static

Extracts the scale from a UnityEngine.Matrix4x4.

Parameters
matrixUnityEngine.Matrix4x4 to extract from.
Returns
Extracted scale UnityEngine.Vector3.
//Creates a matrix that moves 100 units forward at world space, then rotates 90 units on y-axis at local space
var myMatrix = Matrix4x4.TRS(new Vector3(0f, 0f, 100f), Quaternion.Euler(0f, 90f, 0f), Vector3.one);
//Assigns the local scale contained in the "myMatrix" to "myGameObject"
myGameObject.transform.localScale = myMatrix.ExtractScale();

The documentation for this class was generated from the following file: