Table of Contents

Class Fixed4x4Extensions

Namespace
FixedMathSharp
Assembly
FixedMathSharp.dll

Provides extension methods for the Fixed4x4 structure to simplify common matrix operations such as extracting scale, setting transformation components, and transforming points.

public static class Fixed4x4Extensions
Inheritance
Fixed4x4Extensions
Inherited Members

Methods

Decompose(Fixed4x4, out Vector3d, out FixedQuaternion, out Vector3d)

Attempts to decompose an affine 4x4 matrix into strict translation, rotation, and canonical lossy-scale components.

public static bool Decompose(this Fixed4x4 matrix, out Vector3d translation, out FixedQuaternion rotation, out Vector3d scale)

Parameters

matrix Fixed4x4

The 4x4 matrix to decompose.

translation Vector3d

The extracted translation component.

rotation FixedQuaternion

The extracted rotation component as a quaternion.

scale Vector3d

The extracted scale component.

Returns

bool

True if decomposition was successful, otherwise false.

Remarks

Perspective, shear, singular or unrepresentable basis magnitudes, and rotation bases that cannot round-trip within Epsilon are rejected. Reflections assign their single negative scale sign to X. Every failure writes zero translation, identity rotation, and unit scale.

ExtractLossyScale(Fixed4x4)

Extracts canonical signed lossy scale from the matrix basis rows.

public static Vector3d ExtractLossyScale(this Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Vector3d

Remarks

A reflected basis assigns its one recoverable negative sign to X.

ExtractRotation(Fixed4x4)

Extracts the rotation component from the 4x4 matrix by normalizing the rotation matrix.

public static FixedQuaternion ExtractRotation(this Fixed4x4 matrix)

Parameters

matrix Fixed4x4

The matrix from which to extract the rotation.

Returns

FixedQuaternion

A FixedQuaternion representing the rotation component.

ExtractScaleMagnitudes(Fixed4x4)

Extracts the unsigned magnitudes of the matrix basis rows.

public static Vector3d ExtractScaleMagnitudes(this Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Vector3d

The nonnegative basis magnitudes along X, Y, and Z.

ExtractTranslation(Fixed4x4)

Extracts the translation component from the 4x4 matrix.

public static Vector3d ExtractTranslation(this Fixed4x4 matrix)

Parameters

matrix Fixed4x4

The matrix from which to extract the translation.

Returns

Vector3d

A Vector3d representing the translation component.

FuzzyEqual(Fixed4x4, Fixed4x4, Fixed64?)

Compares two Fixed4x4 for approximate equality, allowing a fractional percentage (defaults to ~1%) difference between components.

public static bool FuzzyEqual(this Fixed4x4 f1, Fixed4x4 f2, Fixed64? percentage = null)

Parameters

f1 Fixed4x4

The current Fixed4x4.

f2 Fixed4x4

The Fixed4x4 to compare against.

percentage Fixed64?

The allowed fractional difference (percentage) for each component.

Returns

bool

True if the components are within the allowed percentage difference, false otherwise.

FuzzyEqualAbsolute(Fixed4x4, Fixed4x4, Fixed64)

Compares two Fixed4x4 for approximate equality, allowing a fixed absolute difference between components.

public static bool FuzzyEqualAbsolute(this Fixed4x4 f1, Fixed4x4 f2, Fixed64 allowedDifference)

Parameters

f1 Fixed4x4

The current Fixed4x4.

f2 Fixed4x4

The Fixed4x4 to compare against.

allowedDifference Fixed64

The allowed absolute difference between each component.

Returns

bool

True if the components are within the allowed difference, false otherwise.

InverseTransformPoint(Fixed4x4, Vector3d)

Transforms a point from world space into the local space of the matrix.

public static Vector3d InverseTransformPoint(this Fixed4x4 matrix, Vector3d point)

Parameters

matrix Fixed4x4

The transformation matrix.

point Vector3d

The world-space point.

Returns

Vector3d

The local-space point relative to the transformation matrix.

Lerp(Fixed4x4, Fixed4x4, Fixed64)

Linearly interpolates between two matrices component-wise.

public static Fixed4x4 Lerp(this Fixed4x4 matrix, Fixed4x4 target, Fixed64 amount)

Parameters

matrix Fixed4x4
target Fixed4x4
amount Fixed64

Returns

Fixed4x4

NormalizeRotationMatrix(ref Fixed4x4)

Normalizes the rotation component of a 4x4 matrix by ensuring the basis vectors are orthogonal and unit length.

public static Fixed4x4 NormalizeRotationMatrix(this ref Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Fixed4x4

Remarks

This method recalculates the X, Y, and Z basis vectors from the upper-left 3x3 portion of the matrix, ensuring they are orthogonal and normalized. The remaining components of the matrix are reset to maintain a valid transformation structure.

Use Cases:

  • Ensuring the rotation component remains stable and accurate after multiple transformations.
  • Used in 3D transformations to prevent numerical drift from affecting the orientation over time.
  • Essential for cases where precise orientation is required, such as animations or physics simulations.

SetRotation(ref Fixed4x4, FixedQuaternion)

Replaces the rotation component of the 4x4 matrix using the provided quaternion, without affecting the translation component.

public static Fixed4x4 SetRotation(this ref Fixed4x4 matrix, FixedQuaternion rotation)

Parameters

matrix Fixed4x4

The matrix to modify. The rotation will replace the upper-left 3x3 portion of the matrix.

rotation FixedQuaternion

The quaternion representing the new rotation to apply.

Returns

Fixed4x4

Remarks

Quaternion magnitude does not affect the replacement rotation; zero represents identity. This method preserves the matrix's translation component. For complete transformation updates, use SetTransform(Vector3d, FixedQuaternion, Vector3d).

SetTranslation(ref Fixed4x4, Vector3d)

Sets the translation component of the 4x4 matrix.

public static Fixed4x4 SetTranslation(this ref Fixed4x4 matrix, Vector3d position)

Parameters

matrix Fixed4x4

The matrix to modify.

position Vector3d

Returns

Fixed4x4

Transform(Fixed4x4, Vector4d)

Transforms a 4D vector by a 4x4 matrix, preserving the computed W component.

public static Vector4d Transform(this Fixed4x4 matrix, Vector4d vector)

Parameters

matrix Fixed4x4
vector Vector4d

Returns

Vector4d

TransformPoint(Fixed4x4, Vector3d)

Transforms a point from local space to world space using this transformation matrix.

public static Vector3d TransformPoint(this Fixed4x4 matrix, Vector3d point)

Parameters

matrix Fixed4x4

The transformation matrix.

point Vector3d

The local-space point.

Returns

Vector3d

The transformed point in world space.

Remarks

FixedMathSharp applies matrices using a row-vector convention: point * matrix. This is equivalent to operator *(Vector3d, Fixed4x4).

Transpose(Fixed4x4)

Transposes the matrix by swapping rows and columns.

public static Fixed4x4 Transpose(this Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Fixed4x4