MatrixDecomposition Type
A struct containing 13 floats, representing an immutable affine 4x4 Matrix decomposed into translation, rotation, scale and shear. Use Matrix.decompose to create one, and d.ToMatrix to recompose it. The components are applied to a point in this order: first Scale, then Shear, then Rotation and last Translation. So the recomposed matrix is the same as:
Matrix.createScale d.ScaleX d.ScaleY d.ScaleZ
*** Matrix.createShear(0, 0, d.ShearYX, 0, d.ShearZX, d.ShearZY)
*** Matrix.createFromQuaternion d.Rotation
*** Matrix.createTranslation d.Translation
The shear is upper triangular, so the X-axis is never sheared, the Y-axis is only sheared towards the X-axis,
and the Z-axis is sheared towards the X- and Y-axis.
A mirroring matrix has a negative ScaleX.
Interpolating two decompositions component by component gives smooth animations between two matrices.
Note: Never use the struct default constructor MatrixDecomposition() as it will create an invalid zero rotation.
Use MatrixDecomposition.create instead.
Record fields
| Record Field |
Description
|
Full Usage:
RotationW
Field type: float
|
The W component of the rotation quaternion.
|
Full Usage:
RotationX
Field type: float
|
The X component of the rotation quaternion.
|
Full Usage:
RotationY
Field type: float
|
The Y component of the rotation quaternion.
|
Full Usage:
RotationZ
Field type: float
|
The Z component of the rotation quaternion.
|
Full Usage:
ScaleX
Field type: float
|
The scale factor along the X-axis. It is negative for mirroring matrices.
|
Full Usage:
ScaleY
Field type: float
|
The scale factor along the Y-axis.
|
Full Usage:
ScaleZ
Field type: float
|
The scale factor along the Z-axis.
|
Full Usage:
ShearYX
Field type: float
|
The amount to shear the X component when moving along the Y-axis. Same as the yx argument of Matrix.createShear.
|
Full Usage:
ShearZX
Field type: float
|
The amount to shear the X component when moving along the Z-axis. Same as the zx argument of Matrix.createShear.
|
Full Usage:
ShearZY
Field type: float
|
The amount to shear the Y component when moving along the Z-axis. Same as the zy argument of Matrix.createShear.
|
Full Usage:
TranslationX
Field type: float
|
The X component of the translation.
|
Full Usage:
TranslationY
Field type: float
|
The Y component of the translation.
|
Full Usage:
TranslationZ
Field type: float
|
The Z component of the translation.
|
Instance members
| Instance member |
Description
|
Full Usage:
this.AsFSharpCode
Returns: string
|
Formats the decomposition into an F# code string that can be used to recreate it.
|
Full Usage:
this.AsString
Returns: string
|
Nicely formats the decomposition, showing the rotation axis and angle.
|
Full Usage:
this.Interpolate
Parameters:
MatrixDecomposition
-
The decomposition at factor 1.
factor : float
-
The finite interpolation factor.
Returns: MatrixDecomposition
A new interpolated MatrixDecomposition.
|
Interpolates from this decomposition to finish. The translation, scale and shear are interpolated linearly. The rotation is interpolated with Quaternion.slerp along the shortest rotation, at a constant angular speed. Factor 0 returns this decomposition and factor 1 returns finish, but finish's rotation might have all components negated. The factor is not clamped: negative factors and factors above one extrapolate. If the scale of one axis changes its sign, the interpolated matrix collapses on the way, when this scale passes zero. Fails if the factor is not finite.
|
|
Returns the rotation part as a unit quaternion.
|
|
Returns the three scale factors as a vector.
|
|
Recomposes the 4x4 Matrix: first scale, then shear, then rotate and last translate.
|
|
Returns the translation part as a vector.
|
Static members
| Static member |
Description
|
|
Returns the decomposition of the identity matrix: no translation, no rotation, a scale of one and no shear.
|
Full Usage:
MatrixDecomposition.asFSharpCode d
Parameters: Returns: string
Modifiers: inline |
Formats the decomposition into an F# code string that can be used to recreate it.
|
Full Usage:
MatrixDecomposition.asString d
Parameters: Returns: string
Modifiers: inline |
Nicely formats the decomposition, showing the rotation axis and angle.
|
Full Usage:
MatrixDecomposition.create translation rotation scale shearYX shearZX shearZY
Parameters:
Vec
-
The translation, applied last.
rotation : Quaternion
-
The rotation, applied after the shear.
scale : Vec
-
The scale factors along the X-, Y- and Z-axis, applied first.
shearYX : float
-
The amount to shear the X component when moving along the Y-axis, applied after the scale.
shearZX : float
-
The amount to shear the X component when moving along the Z-axis, applied after the scale.
shearZY : float
-
The amount to shear the Y component when moving along the Z-axis, applied after the scale.
Returns: MatrixDecomposition
A new MatrixDecomposition.
|
Creates a decomposition from its components. When recomposed, they are applied to a point in this order: first scale, then shear, then rotate and last translate.
|
Full Usage:
MatrixDecomposition.equalsExact a b
Parameters:
MatrixDecomposition
-
The first decomposition.
b : MatrixDecomposition
-
The second decomposition.
Returns: bool
|
Checks if two decompositions are exactly equal. Compares each field with the = operator, so a NaN value is never equal.
|
Full Usage:
MatrixDecomposition.equalsWithin tol a b
Parameters:
float
-
The tolerance for comparing each field.
a : MatrixDecomposition
-
The first decomposition.
b : MatrixDecomposition
-
The second decomposition.
Returns: bool
|
Checks if two decompositions are equal within tolerance. By comparing the 13 fields from TranslationX to ShearZY each with the given tolerance, not by a Euclidean distance. A rotation quaternion with every component negated represents the same rotation but will be considered unequal. Use MatrixDecomposition.equalsExact to check for an exact match.
|
Full Usage:
MatrixDecomposition.interpolate start finish factor
Parameters:
MatrixDecomposition
-
The decomposition at factor 0.
finish : MatrixDecomposition
-
The decomposition at factor 1.
factor : float
-
The finite interpolation factor.
Returns: MatrixDecomposition
A new interpolated MatrixDecomposition.
Modifiers: inline |
Interpolates from start to finish. The translation, scale and shear are interpolated linearly. The rotation is interpolated with Quaternion.slerp along the shortest rotation, at a constant angular speed. Factor 0 returns start and factor 1 returns finish, but finish's rotation might have all components negated. The factor is not clamped: negative factors and factors above one extrapolate. If the scale of one axis changes its sign, the interpolated matrix collapses on the way, when this scale passes zero. Fails if the factor is not finite.
|
Full Usage:
MatrixDecomposition.toMatrix d
Parameters:
MatrixDecomposition
-
The decomposition to recompose.
Returns: Matrix
Modifiers: inline |
Recomposes the 4x4 Matrix: first scale, then shear, then rotate and last translate.
|
Euclid