Table of Contents

Struct Fixed4x4

Namespace
FixedMathSharp
Assembly
FixedMathSharp.dll

Represents a 4x4 matrix used for transformations in 3D space, including translation, rotation, scaling, and perspective projection.

[MemoryPackable(GenerateType.Object)]
public struct Fixed4x4 : IEquatable<Fixed4x4>, ISpanFormattable, IFormattable, IMemoryPackable<Fixed4x4>, IMemoryPackFormatterRegister
Implements
IMemoryPackable<Fixed4x4>
IMemoryPackFormatterRegister
Inherited Members
Extension Methods

Remarks

A 4x4 matrix is the standard structure for 3D transformations because it can handle both linear transformations (rotation, scaling) and affine transformations (translation, shearing, and perspective projections). It is commonly used in graphics pipelines, game engines, and 3D rendering systems.

FixedMathSharp applies transform matrices with a row-vector convention: point * matrix. Translation is stored in M41, M42, and M43. Direction properties use the canonical 3D basis: +X right, +Y up, and +Z forward.

Use Cases:

  • Transforming objects in 3D space (position, orientation, and size).
  • Combining multiple transformations (e.g., model-view-projection matrices).
  • Applying translations, which require an extra dimension for homogeneous coordinates.
  • Useful in animation, physics engines, and 3D rendering for full transformation control.

Constructors

Fixed4x4(Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64)

Initializes a new FixedMatrix4x4 with individual elements.

public Fixed4x4(Fixed64 m11, Fixed64 m12, Fixed64 m13, Fixed64 m14, Fixed64 m21, Fixed64 m22, Fixed64 m23, Fixed64 m24, Fixed64 m31, Fixed64 m32, Fixed64 m33, Fixed64 m34, Fixed64 m41, Fixed64 m42, Fixed64 m43, Fixed64 m44)

Parameters

m11 Fixed64
m12 Fixed64
m13 Fixed64
m14 Fixed64
m21 Fixed64
m22 Fixed64
m23 Fixed64
m24 Fixed64
m31 Fixed64
m32 Fixed64
m33 Fixed64
m34 Fixed64
m41 Fixed64
m42 Fixed64
m43 Fixed64
m44 Fixed64

Fields

Identity

Returns the identity matrix (diagonal elements set to 1).

public static readonly Fixed4x4 Identity

Field Value

Fixed4x4

M11

Represents the element in the first row and first column of the matrix.

[JsonInclude]
[MemoryPackOrder(0)]
public Fixed64 M11

Field Value

Fixed64

M12

Represents the element in the first row and second column of the matrix.

[JsonInclude]
[MemoryPackOrder(1)]
public Fixed64 M12

Field Value

Fixed64

M13

Represents the element in the first row and third column of the matrix.

[JsonInclude]
[MemoryPackOrder(2)]
public Fixed64 M13

Field Value

Fixed64

M14

Represents the element in the first row and fourth column of the matrix.

[JsonInclude]
[MemoryPackOrder(3)]
public Fixed64 M14

Field Value

Fixed64

M21

Represents the element in the second row and first column of the matrix.

[JsonInclude]
[MemoryPackOrder(4)]
public Fixed64 M21

Field Value

Fixed64

M22

Represents the element in the second row and second column of the matrix.

[JsonInclude]
[MemoryPackOrder(5)]
public Fixed64 M22

Field Value

Fixed64

M23

Represents the element in the second row and third column of the matrix.

[JsonInclude]
[MemoryPackOrder(6)]
public Fixed64 M23

Field Value

Fixed64

M24

Represents the element in the second row and fourth column of the matrix.

[JsonInclude]
[MemoryPackOrder(7)]
public Fixed64 M24

Field Value

Fixed64

M31

Represents the element in the third row and first column of the matrix.

[JsonInclude]
[MemoryPackOrder(8)]
public Fixed64 M31

Field Value

Fixed64

M32

Represents the element in the third row and second column of the matrix.

[JsonInclude]
[MemoryPackOrder(9)]
public Fixed64 M32

Field Value

Fixed64

M33

Represents the element in the third row and third column of the matrix.

[JsonInclude]
[MemoryPackOrder(10)]
public Fixed64 M33

Field Value

Fixed64

M34

Represents the element in the third row and fourth column of the matrix.

[JsonInclude]
[MemoryPackOrder(11)]
public Fixed64 M34

Field Value

Fixed64

M41

Represents the element in the fourth row and first column of the matrix.

[JsonInclude]
[MemoryPackOrder(12)]
public Fixed64 M41

Field Value

Fixed64

M42

Represents the element in the fourth row and second column of the matrix.

[JsonInclude]
[MemoryPackOrder(13)]
public Fixed64 M42

Field Value

Fixed64

M43

Represents the element in the fourth row and third column of the matrix.

[JsonInclude]
[MemoryPackOrder(14)]
public Fixed64 M43

Field Value

Fixed64

M44

Represents the element in the fourth row and fourth column of the matrix.

[JsonInclude]
[MemoryPackOrder(15)]
public Fixed64 M44

Field Value

Fixed64

Zero

Returns a matrix with all elements set to zero.

public static readonly Fixed4x4 Zero

Field Value

Fixed4x4

Properties

Backward

Gets the backward direction vector for this instance.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Backward { get; }

Property Value

Vector3d

Down

Gets the downward direction vector for this instance.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Down { get; }

Property Value

Vector3d

Forward

Gets the canonical forward direction vector for this instance.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Forward { get; }

Property Value

Vector3d

Remarks

FixedMathSharp defines semantic forward as +Z. Convert external matrix or transform conventions at adapter boundaries before relying on this basis extraction.

IsAffine

Gets a value indicating whether the matrix represents an affine transformation.

[JsonIgnore]
[MemoryPackIgnore]
public readonly bool IsAffine { get; }

Property Value

bool

Remarks

An affine transformation is one where the bottom row is (0, 0, 0, 1), allowing for efficient operations such as translation, scaling, rotation, and shearing without perspective distortion.

this[int]

Gets or sets the matrix element at the specified linear index.

[JsonIgnore]
[MemoryPackIgnore]
public Fixed64 this[int index] { get; set; }

Parameters

index int

The zero-based linear index of the matrix element to get or set. Must be in the range 0 to 15.

Property Value

Fixed64

The matrix element at the specified index.

Remarks

Matrix elements are indexed in row-major order from 0 to 15.

Exceptions

IndexOutOfRangeException

Thrown when the specified index is less than 0 or greater than 15.

Left

Gets the left direction vector for this instance.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Left { get; }

Property Value

Vector3d

LossyScale

Extracts canonical signed lossy scale from the matrix basis rows.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d LossyScale { get; }

Property Value

Vector3d

Remarks

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

Right

Gets the right direction vector for this instance.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Right { get; }

Property Value

Vector3d

Rotation

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

[JsonIgnore]
[MemoryPackIgnore]
public readonly FixedQuaternion Rotation { get; }

Property Value

FixedQuaternion

A FixedQuaternion representing the rotation component.

Translation

Extracts the translation component from the 4x4 matrix.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Translation { get; }

Property Value

Vector3d

A Vector3d representing the translation component.

Up

Gets the upward direction vector for this instance.

[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Up { get; }

Property Value

Vector3d

Methods

ApplyScaleToRotation(Fixed4x4, Vector3d)

Applies non-uniform scaling to the 4x4 matrix by multiplying the scale vector with the rotation matrix's basis vectors.

public static Fixed4x4 ApplyScaleToRotation(Fixed4x4 matrix, Vector3d scale)

Parameters

matrix Fixed4x4

The matrix to modify. Should already contain a valid rotation component.

scale Vector3d

The scale vector to apply along the X, Y, and Z axes.

Returns

Fixed4x4

Remarks

Use this method when scaling is required in combination with an existing rotation, ensuring proper axis alignment.

ComponentDivide(Fixed4x4, Fixed4x4)

Divides each component of one matrix by the corresponding component of another matrix.

public static Fixed4x4 ComponentDivide(Fixed4x4 dividend, Fixed4x4 divisor)

Parameters

dividend Fixed4x4
divisor Fixed4x4

Returns

Fixed4x4

Exceptions

DivideByZeroException

Thrown when any divisor component is zero.

CreateFromAxisAngle(Vector3d, Fixed64)

Creates a rotation matrix from an axis and angle.

public static Fixed4x4 CreateFromAxisAngle(Vector3d axis, Fixed64 angle)

Parameters

axis Vector3d
angle Fixed64

Returns

Fixed4x4

CreateFromEulerAngles(Fixed64, Fixed64, Fixed64)

Creates a rotation matrix from pitch, yaw, and roll angles in radians.

public static Fixed4x4 CreateFromEulerAngles(Fixed64 pitch, Fixed64 yaw, Fixed64 roll)

Parameters

pitch Fixed64
yaw Fixed64
roll Fixed64

Returns

Fixed4x4

CreateLookAt(Vector3d, Vector3d, Vector3d)

Creates a view matrix looking from a camera position toward a target.

public static Fixed4x4 CreateLookAt(Vector3d cameraPosition, Vector3d cameraTarget, Vector3d cameraUpVector)

Parameters

cameraPosition Vector3d
cameraTarget Vector3d
cameraUpVector Vector3d

Returns

Fixed4x4

Remarks

The view direction is expressed in FixedMathSharp's canonical +Z-forward basis and the resulting matrix follows the row-vector convention used by TransformPoint(Fixed4x4, Vector3d). Convert engine-specific camera conventions at adapter boundaries.

CreateOrthographic(Fixed64, Fixed64, Fixed64, Fixed64)

Creates an orthographic projection matrix centered on the origin.

public static Fixed4x4 CreateOrthographic(Fixed64 width, Fixed64 height, Fixed64 zNearPlane, Fixed64 zFarPlane)

Parameters

width Fixed64
height Fixed64
zNearPlane Fixed64
zFarPlane Fixed64

Returns

Fixed4x4

CreateOrthographicOffCenter(Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64)

Creates an off-center orthographic projection matrix.

public static Fixed4x4 CreateOrthographicOffCenter(Fixed64 left, Fixed64 right, Fixed64 bottom, Fixed64 top, Fixed64 zNearPlane, Fixed64 zFarPlane)

Parameters

left Fixed64
right Fixed64
bottom Fixed64
top Fixed64
zNearPlane Fixed64
zFarPlane Fixed64

Returns

Fixed4x4

CreatePerspective(Fixed64, Fixed64, Fixed64, Fixed64)

Creates a perspective projection matrix centered on the near plane.

public static Fixed4x4 CreatePerspective(Fixed64 width, Fixed64 height, Fixed64 nearPlaneDistance, Fixed64 farPlaneDistance)

Parameters

width Fixed64
height Fixed64
nearPlaneDistance Fixed64
farPlaneDistance Fixed64

Returns

Fixed4x4

CreatePerspectiveFieldOfView(Fixed64, Fixed64, Fixed64, Fixed64)

Creates a perspective projection matrix from a vertical field of view.

public static Fixed4x4 CreatePerspectiveFieldOfView(Fixed64 fieldOfView, Fixed64 aspectRatio, Fixed64 nearPlaneDistance, Fixed64 farPlaneDistance)

Parameters

fieldOfView Fixed64
aspectRatio Fixed64
nearPlaneDistance Fixed64
farPlaneDistance Fixed64

Returns

Fixed4x4

CreatePerspectiveOffCenter(Fixed64, Fixed64, Fixed64, Fixed64, Fixed64, Fixed64)

Creates an off-center perspective projection matrix.

public static Fixed4x4 CreatePerspectiveOffCenter(Fixed64 left, Fixed64 right, Fixed64 bottom, Fixed64 top, Fixed64 nearPlaneDistance, Fixed64 farPlaneDistance)

Parameters

left Fixed64
right Fixed64
bottom Fixed64
top Fixed64
nearPlaneDistance Fixed64
farPlaneDistance Fixed64

Returns

Fixed4x4

CreateRotation(FixedQuaternion)

Creates a rotation matrix from a quaternion.

public static Fixed4x4 CreateRotation(FixedQuaternion rotation)

Parameters

rotation FixedQuaternion

The quaternion representing the rotation.

Returns

Fixed4x4

A 4x4 matrix representing the rotation.

Remarks

Quaternion magnitude does not affect the result; zero represents identity.

CreateRotationX(Fixed64)

Creates a rotation matrix around the X axis.

public static Fixed4x4 CreateRotationX(Fixed64 angle)

Parameters

angle Fixed64

Returns

Fixed4x4

CreateRotationY(Fixed64)

Creates a rotation matrix around the Y axis.

public static Fixed4x4 CreateRotationY(Fixed64 angle)

Parameters

angle Fixed64

Returns

Fixed4x4

CreateRotationZ(Fixed64)

Creates a rotation matrix around the Z axis.

public static Fixed4x4 CreateRotationZ(Fixed64 angle)

Parameters

angle Fixed64

Returns

Fixed4x4

CreateScale(Fixed64)

Creates a uniform scale matrix.

public static Fixed4x4 CreateScale(Fixed64 scale)

Parameters

scale Fixed64

Returns

Fixed4x4

CreateScale(Fixed64, Fixed64, Fixed64)

Creates a non-uniform scale matrix from individual scale components.

public static Fixed4x4 CreateScale(Fixed64 x, Fixed64 y, Fixed64 z)

Parameters

x Fixed64
y Fixed64
z Fixed64

Returns

Fixed4x4

CreateScale(Vector3d)

Creates a scale matrix from a 3-dimensional vector.

public static Fixed4x4 CreateScale(Vector3d scale)

Parameters

scale Vector3d

The vector representing the scale along each axis.

Returns

Fixed4x4

A 4x4 matrix representing the scale transformation.

CreateTransform(Vector3d, FixedQuaternion, Vector3d)

Constructs a transformation matrix from translation, scale, and rotation. This method ensures that the rotation is properly normalized, applies the scale to the rotational basis, and sets the translation component separately.

public static Fixed4x4 CreateTransform(Vector3d translation, FixedQuaternion rotation, Vector3d scale)

Parameters

translation Vector3d

The translation vector.

rotation FixedQuaternion

The rotation quaternion.

scale Vector3d

The scale vector.

Returns

Fixed4x4

A transformation matrix incorporating translation, rotation, and scale.

Remarks

  • Quaternion magnitude does not affect the rotation matrix; zero represents identity.
  • Applies non-uniform scaling to the rotation before setting translation.
  • Preferred when ensuring transformations remain mathematically correct.
  • For explicit matrix-composition order, see ScaleRotateTranslate(Vector3d, FixedQuaternion, Vector3d).

CreateTranslation(Fixed64, Fixed64, Fixed64)

Creates a translation matrix from the specified coordinates.

public static Fixed4x4 CreateTranslation(Fixed64 x, Fixed64 y, Fixed64 z)

Parameters

x Fixed64
y Fixed64
z Fixed64

Returns

Fixed4x4

CreateTranslation(Vector3d)

Creates a translation matrix from the specified 3-dimensional vector.

public static Fixed4x4 CreateTranslation(Vector3d position)

Parameters

position Vector3d

Returns

Fixed4x4

The translation matrix.

CreateWorld(Vector3d, Vector3d, Vector3d)

Creates a world matrix from a position and orientation basis.

public static Fixed4x4 CreateWorld(Vector3d position, Vector3d forward, Vector3d up)

Parameters

position Vector3d
forward Vector3d
up Vector3d

Returns

Fixed4x4

Remarks

The forward and up vectors are semantic basis vectors in FixedMathSharp's canonical coordinate space. The returned matrix stores right, up, and forward basis rows for row-vector transforms.

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(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.

Equals(Fixed4x4)

public bool Equals(Fixed4x4 other)

Parameters

other Fixed4x4

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

ExtractForward(Fixed4x4)

Extracts the forward direction from the 4x4 matrix.

public static Vector3d ExtractForward(Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Vector3d

ExtractLossyScale(Fixed4x4)

Extracts canonical signed lossy scale from the matrix basis rows.

public static Vector3d ExtractLossyScale(Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Vector3d

Remarks

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

ExtractRight(Fixed4x4)

Extracts the right direction from the 4x4 matrix.

public static Vector3d ExtractRight(Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Vector3d

ExtractRotation(Fixed4x4)

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

public static FixedQuaternion ExtractRotation(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(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(Fixed4x4 matrix)

Parameters

matrix Fixed4x4

The matrix from which to extract the translation.

Returns

Vector3d

A Vector3d representing the translation component.

ExtractUp(Fixed4x4)

Extracts the up direction from the 4x4 matrix.

public static Vector3d ExtractUp(Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Vector3d

A Vector3d representing the up direction.

Remarks

This is the surface normal if the matrix represents ground orientation.

FromColumns(Vector4d, Vector4d, Vector4d, Vector4d)

Creates a matrix from four column vectors.

public static Fixed4x4 FromColumns(Vector4d column1, Vector4d column2, Vector4d column3, Vector4d column4)

Parameters

column1 Vector4d
column2 Vector4d
column3 Vector4d
column4 Vector4d

Returns

Fixed4x4

FromRows(Vector4d, Vector4d, Vector4d, Vector4d)

Creates a matrix from four row vectors.

public static Fixed4x4 FromRows(Vector4d row1, Vector4d row2, Vector4d row3, Vector4d row4)

Parameters

row1 Vector4d
row2 Vector4d
row3 Vector4d
row4 Vector4d

Returns

Fixed4x4

GetDeterminant()

Calculates the determinant of a 4x4 matrix.

public Fixed64 GetDeterminant()

Returns

Fixed64

GetHashCode()

public override int GetHashCode()

Returns

int

InverseDivide(Fixed4x4, Fixed4x4)

Divides one matrix by another using inverse matrix division.

public static Fixed4x4 InverseDivide(Fixed4x4 dividend, Fixed4x4 divisor)

Parameters

dividend Fixed4x4
divisor Fixed4x4

Returns

Fixed4x4

Remarks

This is equivalent to dividend * Invert(divisor). Use ComponentDivide(Fixed4x4, Fixed4x4) when each matrix component should be divided by the corresponding component of another matrix.

Exceptions

InvalidOperationException

Thrown when divisor is not invertible.

InverseTransformPoint(Fixed4x4, Vector3d)

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

public static Vector3d InverseTransformPoint(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.

Invert(Fixed4x4, out Fixed4x4)

Inverts the matrix if it is invertible (i.e., if the determinant is not zero).

public static bool Invert(Fixed4x4 matrix, out Fixed4x4 result)

Parameters

matrix Fixed4x4
result Fixed4x4

Returns

bool

Remarks

To Invert a FixedMatrix4x4, we need to calculate the inverse for each element. This involves computing the cofactor for each element, which is the determinant of the submatrix when the row and column of that element are removed, multiplied by a sign based on the element's position. After computing all cofactors, the result is transposed to get the inverse matrix.

Lerp(Fixed4x4, Fixed4x4, Fixed64)

Linearly interpolates between two matrices component-wise.

public static Fixed4x4 Lerp(Fixed4x4 a, Fixed4x4 b, Fixed64 t)

Parameters

a Fixed4x4
b Fixed4x4
t Fixed64

Returns

Fixed4x4

NormalizeRotationMatrix(Fixed4x4)

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

public static Fixed4x4 NormalizeRotationMatrix(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.

ScaleRotateTranslate(Vector3d, FixedQuaternion, Vector3d)

Constructs a transformation matrix from translation, rotation, and scale by multiplying separate matrices in the order: Scale * Rotation * Translation.

public static Fixed4x4 ScaleRotateTranslate(Vector3d translation, FixedQuaternion rotation, Vector3d scale)

Parameters

translation Vector3d
rotation FixedQuaternion
scale Vector3d

Returns

Fixed4x4

Remarks

  • This method directly multiplies the scale, rotation, and translation matrices.
  • Ensures that scale is applied first to preserve correct axis scaling.
  • Then rotation is applied so that rotation is not affected by non-uniform scaling.
  • Finally, translation moves the object to its correct world position.

SetRotation(Fixed4x4, FixedQuaternion)

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

public static Fixed4x4 SetRotation(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).

SetTransform(Vector3d, FixedQuaternion, Vector3d)

Sets the translation, scale, and rotation components onto the matrix.

public void SetTransform(Vector3d translation, FixedQuaternion rotation, Vector3d scale)

Parameters

translation Vector3d

The translation vector.

rotation FixedQuaternion

The rotation quaternion.

scale Vector3d

The scale vector.

SetTranslation(Fixed4x4, Vector3d)

Sets the translation component of the 4x4 matrix.

public static Fixed4x4 SetTranslation(Fixed4x4 matrix, Vector3d translation)

Parameters

matrix Fixed4x4

The matrix to modify.

translation Vector3d

The new translation vector.

Returns

Fixed4x4

ToString()

Returns a string that represents the current matrix in a readable format.

public override string ToString()

Returns

string

ToString(string?, IFormatProvider?)

Returns a string that represents the current matrix in a readable format.

public string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string
formatProvider IFormatProvider

Returns

string

Transform(Fixed4x4, Vector4d)

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

public static Vector4d Transform(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(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).

TranslateRotateScale(Vector3d, FixedQuaternion, Vector3d)

Constructs a transformation matrix from translation, rotation, and scale by multiplying matrices in the order: Translation * Rotation * Scale (T * R * S).

public static Fixed4x4 TranslateRotateScale(Vector3d translation, FixedQuaternion rotation, Vector3d scale)

Parameters

translation Vector3d
rotation FixedQuaternion
scale Vector3d

Returns

Fixed4x4

Remarks

  • Use this method when transformations need to be applied relative to an object's local origin.
  • Example use cases include animation systems, hierarchical transformations, and UI transformations.
  • If you need to apply world-space transformations, use CreateTransform(Vector3d, FixedQuaternion, Vector3d) instead.
  • Quaternion magnitude does not affect the rotation matrix; zero represents identity.

Transpose(Fixed4x4)

Transposes the matrix by swapping rows and columns.

public static Fixed4x4 Transpose(Fixed4x4 matrix)

Parameters

matrix Fixed4x4

Returns

Fixed4x4

TryExtractLossyScale(Fixed4x4, out Vector3d)

Attempts to extract canonical signed lossy scale from the matrix basis rows.

public static bool TryExtractLossyScale(Fixed4x4 matrix, out Vector3d scale)

Parameters

matrix Fixed4x4
scale Vector3d

Returns

bool

Remarks

This operation accepts affine, non-affine, singular, and sheared matrices. It fails only when at least one basis-row magnitude is outside the representable Fixed64 range. A reflected basis assigns its one recoverable negative sign to X. Every failure writes zero.

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

Formats this matrix into the provided destination buffer.

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)

Parameters

destination Span<char>
charsWritten int
format ReadOnlySpan<char>
provider IFormatProvider

Returns

bool

TryMultiply(Fixed4x4, Fixed4x4, out Fixed4x4)

Attempts to multiply two matrices with one exact, round-half-to-even conversion per cell.

public static bool TryMultiply(Fixed4x4 lhs, Fixed4x4 rhs, out Fixed4x4 result)

Parameters

lhs Fixed4x4
rhs Fixed4x4
result Fixed4x4

Returns

bool

Remarks

Unlike operator *(Fixed4x4, Fixed4x4), this method does not saturate intermediate products or partial sums. On failure, result is zero.

TryTransformAffinePoint(Fixed4x4, Vector3d, out Vector3d)

Attempts to transform a point by an affine matrix without intermediate saturation.

public static bool TryTransformAffinePoint(Fixed4x4 matrix, Vector3d point, out Vector3d result)

Parameters

matrix Fixed4x4
point Vector3d
result Vector3d

Returns

bool

Remarks

FixedMathSharp applies matrices using the row-vector convention point * matrix. Each result coordinate is accumulated exactly and rounded half to even once. Non-affine matrices and unrepresentable final coordinates fail with a zero result.

Operators

operator +(Fixed4x4, Fixed4x4)

Adds two matrices element-wise.

public static Fixed4x4 operator +(Fixed4x4 lhs, Fixed4x4 rhs)

Parameters

lhs Fixed4x4
rhs Fixed4x4

Returns

Fixed4x4

operator /(Fixed4x4, Fixed64)

Divides every matrix component by a scalar.

public static Fixed4x4 operator /(Fixed4x4 matrix, Fixed64 scalar)

Parameters

matrix Fixed4x4
scalar Fixed64

Returns

Fixed4x4

operator ==(Fixed4x4, Fixed4x4)

Determines whether two Fixed4x4 instances are equal.

public static bool operator ==(Fixed4x4 left, Fixed4x4 right)

Parameters

left Fixed4x4

The first Fixed4x4 instance to compare.

right Fixed4x4

The second Fixed4x4 instance to compare.

Returns

bool

true if the specified Fixed4x4 instances are equal; otherwise, false.

operator !=(Fixed4x4, Fixed4x4)

Determines whether two Fixed4x4 instances are not equal.

public static bool operator !=(Fixed4x4 left, Fixed4x4 right)

Parameters

left Fixed4x4

The first Fixed4x4 instance to compare.

right Fixed4x4

The second Fixed4x4 instance to compare.

Returns

bool

true if the specified Fixed4x4 instances are not equal; otherwise, false.

operator *(Fixed4x4, Fixed4x4)

Multiplies two 4x4 matrices using standard matrix multiplication.

public static Fixed4x4 operator *(Fixed4x4 lhs, Fixed4x4 rhs)

Parameters

lhs Fixed4x4
rhs Fixed4x4

Returns

Fixed4x4

operator *(Fixed4x4, Fixed64)

Multiplies every matrix component by a scalar.

public static Fixed4x4 operator *(Fixed4x4 matrix, Fixed64 scalar)

Parameters

matrix Fixed4x4
scalar Fixed64

Returns

Fixed4x4

operator *(Fixed64, Fixed4x4)

Multiplies every matrix component by a scalar.

public static Fixed4x4 operator *(Fixed64 scalar, Fixed4x4 matrix)

Parameters

scalar Fixed64
matrix Fixed4x4

Returns

Fixed4x4

operator -(Fixed4x4, Fixed4x4)

Subtracts two matrices element-wise.

public static Fixed4x4 operator -(Fixed4x4 lhs, Fixed4x4 rhs)

Parameters

lhs Fixed4x4
rhs Fixed4x4

Returns

Fixed4x4

operator -(Fixed4x4)

Negates the specified matrix by multiplying all its values by -1.

public static Fixed4x4 operator -(Fixed4x4 value)

Parameters

value Fixed4x4

Returns

Fixed4x4