Struct AffineTransform

AffineTransform structure

Represents an affine transform in 3D space, with two mutually exclusive representantions:

public struct AffineTransform : IEquatable<AffineTransform>

Constructors

NameDescription
AffineTransform(Matrix4x4)
AffineTransform(Quaternion)
AffineTransform(Quaternion, Vector3)
AffineTransform(Vector3, Quaternion, Vector3)
AffineTransform(Vector3?, Quaternion?, Vector3?)

Properties

NameDescription
IsIdentity { get; }
IsLosslessDecomposable { get; }Gets a value indicating whether this transform can be decomposed to SRT without precission loss.
IsMatrix { get; }Gets a value indicating whether this AffineTransform represents a Matrix4x4.
IsSRT { get; }Gets a value indicating whether this AffineTransform represents a SRT chain.
IsValid { get; }
Matrix { get; }Gets the Matrix4x4 transform of the current AffineTransform
Rotation { get; }Gets the rotation.
Scale { get; }Gets the scale.
Translation { get; }Gets the translation

Methods

NameDescription
static Blend(ReadOnlySpan<AffineTransform>, ReadOnlySpan<float>)
static CreateDecomposed(Matrix4x4)
static CreateFromAny(Matrix4x4?, Vector3?, Quaternion?, Vector3?)
static Multiply(ref AffineTransform, ref AffineTransform)Multiplies a by b.
Equals(AffineTransform)
override Equals(object)
GetDecomposed()If this object represents a Matrix4x4, it returns a decomposed representation.
override GetHashCode()
TryDecompose(out AffineTransform)
TryDecompose(out Vector3, out Quaternion, out Vector3)
WithRotation(Quaternion)
WithScale(Vector3)
WithTranslation(Vector3)
static AreGeometricallyEquivalent(ref AffineTransform, ref AffineTransform, float)Checks whether two transform represent the same geometric spatial transformation.
static TransformNormal(Vector3, ref AffineTransform)Transforms a vector normal by a specified transform.
static TryInvert(ref AffineTransform, out AffineTransform)Inverts the specified transform. The return value indicates whether the operation succeeded.
operator ==
implicit operator(3 operators)
operator !=
operator *

Fields

NameDescription
static readonly Identity

Remarks

Depending on how AffineTransform structures are created, the underlaying fields must be interpreted as a Matrix4x3 or a Scale/Rotation/Translation chain.

This approach allows AffineTransform preserving the source transform, avoiding loosing precission when decomposing a matrix, or creating a matrix from a SRT chain.

Decomposing matrices is tricky because not all valid matrices can be decomposed; in particular squewed matrices will fail to decompose.

See Also