Logo Euclid

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

RotationW

Full Usage: RotationW

Field type: float

The W component of the rotation quaternion.

Field type: float

RotationX

Full Usage: RotationX

Field type: float

The X component of the rotation quaternion.

Field type: float

RotationY

Full Usage: RotationY

Field type: float

The Y component of the rotation quaternion.

Field type: float

RotationZ

Full Usage: RotationZ

Field type: float

The Z component of the rotation quaternion.

Field type: float

ScaleX

Full Usage: ScaleX

Field type: float

The scale factor along the X-axis. It is negative for mirroring matrices.

Field type: float

ScaleY

Full Usage: ScaleY

Field type: float

The scale factor along the Y-axis.

Field type: float

ScaleZ

Full Usage: ScaleZ

Field type: float

The scale factor along the Z-axis.

Field type: float

ShearYX

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.

Field type: float

ShearZX

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.

Field type: float

ShearZY

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.

Field type: float

TranslationX

Full Usage: TranslationX

Field type: float

The X component of the translation.

Field type: float

TranslationY

Full Usage: TranslationY

Field type: float

The Y component of the translation.

Field type: float

TranslationZ

Full Usage: TranslationZ

Field type: float

The Z component of the translation.

Field type: float

Instance members

Instance member Description

this.AsFSharpCode

Full Usage: this.AsFSharpCode

Returns: string

Formats the decomposition into an F# code string that can be used to recreate it.

Returns: string

this.AsString

Full Usage: this.AsString

Returns: string

Nicely formats the decomposition, showing the rotation axis and angle.

Returns: string

this.Interpolate

Full Usage: this.Interpolate

Parameters:
    finish : 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.

finish : MatrixDecomposition

The decomposition at factor 1.

factor : float

The finite interpolation factor.

Returns: MatrixDecomposition

A new interpolated MatrixDecomposition.

this.Rotation

Full Usage: this.Rotation

Returns: Quaternion

Returns the rotation part as a unit quaternion.

Returns: Quaternion

this.Scale

Full Usage: this.Scale

Returns: Vec

Returns the three scale factors as a vector.

Returns: Vec

this.ToMatrix

Full Usage: this.ToMatrix

Returns: Matrix
Recomposes the 4x4 Matrix:
 first scale, then shear, then rotate and last translate.
Returns: Matrix

this.Translation

Full Usage: this.Translation

Returns: Vec

Returns the translation part as a vector.

Returns: Vec

Static members

Static member Description

MatrixDecomposition.Identity

Full Usage: MatrixDecomposition.Identity

Returns: MatrixDecomposition
Returns the decomposition of the identity matrix:
 no translation, no rotation, a scale of one and no shear.
Returns: MatrixDecomposition

MatrixDecomposition.asFSharpCode d

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.

d : MatrixDecomposition
Returns: string

MatrixDecomposition.asString d

Full Usage: MatrixDecomposition.asString d

Parameters:
Returns: string
Modifiers: inline

Nicely formats the decomposition, showing the rotation axis and angle.

d : MatrixDecomposition
Returns: string

MatrixDecomposition.create translation rotation scale shearYX shearZX shearZY

Full Usage: MatrixDecomposition.create translation rotation scale shearYX shearZX shearZY

Parameters:
    translation : 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.

translation : 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.

MatrixDecomposition.equalsExact a b

Full Usage: MatrixDecomposition.equalsExact a b

Parameters:
Returns: bool

Checks if two decompositions are exactly equal. Compares each field with the = operator, so a NaN value is never equal.

a : MatrixDecomposition

The first decomposition.

b : MatrixDecomposition

The second decomposition.

Returns: bool

MatrixDecomposition.equalsWithin tol a b

Full Usage: MatrixDecomposition.equalsWithin tol a b

Parameters:
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.

tol : float

The tolerance for comparing each field.

a : MatrixDecomposition

The first decomposition.

b : MatrixDecomposition

The second decomposition.

Returns: bool

MatrixDecomposition.interpolate start finish factor

Full Usage: MatrixDecomposition.interpolate start finish factor

Parameters:
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.

start : 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.

MatrixDecomposition.toMatrix d

Full Usage: MatrixDecomposition.toMatrix d

Parameters:
Returns: Matrix
Modifiers: inline

Recomposes the 4x4 Matrix: first scale, then shear, then rotate and last translate.

d : MatrixDecomposition

The decomposition to recompose.

Returns: Matrix

Type something to start searching.