Skip to content

Matrix4x4d

Unity Equivalent Documentation

Unimplemented Methods

None.

Known Differences Between The Implementations

Equality Checking

While the Unity Matrix4x4 class does have implementations for the == and != operators, there isn't any documentation on them. The same is true for the Equals() method.

I have implemented it such that the operators check for approximate equality, while the Equals() method checks for exact equality. This is what I believe the Unity implementation is.

Static Methods

  • TRS() - When the Unity method is provided a non-unit quaternion, an error is thrown and some matrix is constructed. The implementation used in this package also throws an error and produces some matrix, and that matrix will generally not match the matrix produced by the Unity method.

Instance Methods

  • SetTRS() - When the Unity method is provided a non-unit quaternion, an error is thrown and some matrix is constructed. The implementation used in this package normalises the quaternion to construct a valid TRS matrix.

Properties

  • decomposeProjection - When given a random matrix (not necessarily a projection matrix) the returned frustrum planes do not match. However, this property is generally expected to be used on a projection matrix, and in that case the implementations do match.
  • rotation - There are cases when the returned quaternion does not match. This happens when the matrix contains a net reflection in its scale vector (see lossyScale property). The issue is that a reflection in any one axis is equivalent to a different reflection and a rotation. Thus any given TRS matrix with a net reflection could've been constructed by multiple input scale vectors and rotation quaternions. My implementation assumes that the reflection occured in the x-axis, and returns the corresponding rotation. The Unity implementation appears to vary which axis it considers the reflection to have occurred upon.