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
m11Fixed64m12Fixed64m13Fixed64m14Fixed64m21Fixed64m22Fixed64m23Fixed64m24Fixed64m31Fixed64m32Fixed64m33Fixed64m34Fixed64m41Fixed64m42Fixed64m43Fixed64m44Fixed64
Fields
Identity
Returns the identity matrix (diagonal elements set to 1).
public static readonly Fixed4x4 Identity
Field Value
M11
Represents the element in the first row and first column of the matrix.
[JsonInclude]
[MemoryPackOrder(0)]
public Fixed64 M11
Field Value
M12
Represents the element in the first row and second column of the matrix.
[JsonInclude]
[MemoryPackOrder(1)]
public Fixed64 M12
Field Value
M13
Represents the element in the first row and third column of the matrix.
[JsonInclude]
[MemoryPackOrder(2)]
public Fixed64 M13
Field Value
M14
Represents the element in the first row and fourth column of the matrix.
[JsonInclude]
[MemoryPackOrder(3)]
public Fixed64 M14
Field Value
M21
Represents the element in the second row and first column of the matrix.
[JsonInclude]
[MemoryPackOrder(4)]
public Fixed64 M21
Field Value
M22
Represents the element in the second row and second column of the matrix.
[JsonInclude]
[MemoryPackOrder(5)]
public Fixed64 M22
Field Value
M23
Represents the element in the second row and third column of the matrix.
[JsonInclude]
[MemoryPackOrder(6)]
public Fixed64 M23
Field Value
M24
Represents the element in the second row and fourth column of the matrix.
[JsonInclude]
[MemoryPackOrder(7)]
public Fixed64 M24
Field Value
M31
Represents the element in the third row and first column of the matrix.
[JsonInclude]
[MemoryPackOrder(8)]
public Fixed64 M31
Field Value
M32
Represents the element in the third row and second column of the matrix.
[JsonInclude]
[MemoryPackOrder(9)]
public Fixed64 M32
Field Value
M33
Represents the element in the third row and third column of the matrix.
[JsonInclude]
[MemoryPackOrder(10)]
public Fixed64 M33
Field Value
M34
Represents the element in the third row and fourth column of the matrix.
[JsonInclude]
[MemoryPackOrder(11)]
public Fixed64 M34
Field Value
M41
Represents the element in the fourth row and first column of the matrix.
[JsonInclude]
[MemoryPackOrder(12)]
public Fixed64 M41
Field Value
M42
Represents the element in the fourth row and second column of the matrix.
[JsonInclude]
[MemoryPackOrder(13)]
public Fixed64 M42
Field Value
M43
Represents the element in the fourth row and third column of the matrix.
[JsonInclude]
[MemoryPackOrder(14)]
public Fixed64 M43
Field Value
M44
Represents the element in the fourth row and fourth column of the matrix.
[JsonInclude]
[MemoryPackOrder(15)]
public Fixed64 M44
Field Value
Zero
Returns a matrix with all elements set to zero.
public static readonly Fixed4x4 Zero
Field Value
Properties
Backward
Gets the backward direction vector for this instance.
[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Backward { get; }
Property Value
Down
Gets the downward direction vector for this instance.
[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Down { get; }
Property Value
Forward
Gets the canonical forward direction vector for this instance.
[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d Forward { get; }
Property Value
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
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
indexintThe 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
LossyScale
Extracts canonical signed lossy scale from the matrix basis rows.
[JsonIgnore]
[MemoryPackIgnore]
public readonly Vector3d LossyScale { get; }
Property Value
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
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
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
matrixFixed4x4The matrix to modify. Should already contain a valid rotation component.
scaleVector3dThe scale vector to apply along the X, Y, and Z axes.
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
leftFixed64rightFixed64bottomFixed64topFixed64nearPlaneDistanceFixed64farPlaneDistanceFixed64
Returns
CreateRotation(FixedQuaternion)
Creates a rotation matrix from a quaternion.
public static Fixed4x4 CreateRotation(FixedQuaternion rotation)
Parameters
rotationFixedQuaternionThe 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
angleFixed64
Returns
CreateRotationY(Fixed64)
Creates a rotation matrix around the Y axis.
public static Fixed4x4 CreateRotationY(Fixed64 angle)
Parameters
angleFixed64
Returns
CreateRotationZ(Fixed64)
Creates a rotation matrix around the Z axis.
public static Fixed4x4 CreateRotationZ(Fixed64 angle)
Parameters
angleFixed64
Returns
CreateScale(Fixed64)
Creates a uniform scale matrix.
public static Fixed4x4 CreateScale(Fixed64 scale)
Parameters
scaleFixed64
Returns
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
Returns
CreateScale(Vector3d)
Creates a scale matrix from a 3-dimensional vector.
public static Fixed4x4 CreateScale(Vector3d scale)
Parameters
scaleVector3dThe 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
translationVector3dThe translation vector.
rotationFixedQuaternionThe rotation quaternion.
scaleVector3dThe 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
Returns
CreateTranslation(Vector3d)
Creates a translation matrix from the specified 3-dimensional vector.
public static Fixed4x4 CreateTranslation(Vector3d position)
Parameters
positionVector3d
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
Returns
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
matrixFixed4x4The 4x4 matrix to decompose.
translationVector3dThe extracted translation component.
rotationFixedQuaternionThe extracted rotation component as a quaternion.
scaleVector3dThe 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
otherFixed4x4
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
ExtractForward(Fixed4x4)
Extracts the forward direction from the 4x4 matrix.
public static Vector3d ExtractForward(Fixed4x4 matrix)
Parameters
matrixFixed4x4
Returns
ExtractLossyScale(Fixed4x4)
Extracts canonical signed lossy scale from the matrix basis rows.
public static Vector3d ExtractLossyScale(Fixed4x4 matrix)
Parameters
matrixFixed4x4
Returns
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
matrixFixed4x4
Returns
ExtractRotation(Fixed4x4)
Extracts the rotation component from the 4x4 matrix by normalizing the rotation matrix.
public static FixedQuaternion ExtractRotation(Fixed4x4 matrix)
Parameters
matrixFixed4x4The 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
matrixFixed4x4
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
matrixFixed4x4The 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
matrixFixed4x4
Returns
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
Returns
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
Returns
GetDeterminant()
Calculates the determinant of a 4x4 matrix.
public Fixed64 GetDeterminant()
Returns
GetHashCode()
public override int GetHashCode()
Returns
InverseDivide(Fixed4x4, Fixed4x4)
Divides one matrix by another using inverse matrix division.
public static Fixed4x4 InverseDivide(Fixed4x4 dividend, Fixed4x4 divisor)
Parameters
Returns
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
divisoris 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
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
Returns
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
Returns
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
matrixFixed4x4
Returns
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
translationVector3drotationFixedQuaternionscaleVector3d
Returns
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
matrixFixed4x4The matrix to modify. The rotation will replace the upper-left 3x3 portion of the matrix.
rotationFixedQuaternionThe quaternion representing the new rotation to apply.
Returns
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
translationVector3dThe translation vector.
rotationFixedQuaternionThe rotation quaternion.
scaleVector3dThe scale vector.
SetTranslation(Fixed4x4, Vector3d)
Sets the translation component of the 4x4 matrix.
public static Fixed4x4 SetTranslation(Fixed4x4 matrix, Vector3d translation)
Parameters
Returns
ToString()
Returns a string that represents the current matrix in a readable format.
public override string ToString()
Returns
ToString(string?, IFormatProvider?)
Returns a string that represents the current matrix in a readable format.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringformatProviderIFormatProvider
Returns
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
Returns
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
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
translationVector3drotationFixedQuaternionscaleVector3d
Returns
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
matrixFixed4x4
Returns
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
Returns
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
destinationSpan<char>charsWrittenintformatReadOnlySpan<char>providerIFormatProvider
Returns
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
Returns
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
Returns
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
Returns
operator /(Fixed4x4, Fixed64)
Divides every matrix component by a scalar.
public static Fixed4x4 operator /(Fixed4x4 matrix, Fixed64 scalar)
Parameters
Returns
operator ==(Fixed4x4, Fixed4x4)
Determines whether two Fixed4x4 instances are equal.
public static bool operator ==(Fixed4x4 left, Fixed4x4 right)
Parameters
leftFixed4x4The first Fixed4x4 instance to compare.
rightFixed4x4The 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
leftFixed4x4The first Fixed4x4 instance to compare.
rightFixed4x4The 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
Returns
operator *(Fixed4x4, Fixed64)
Multiplies every matrix component by a scalar.
public static Fixed4x4 operator *(Fixed4x4 matrix, Fixed64 scalar)
Parameters
Returns
operator *(Fixed64, Fixed4x4)
Multiplies every matrix component by a scalar.
public static Fixed4x4 operator *(Fixed64 scalar, Fixed4x4 matrix)
Parameters
Returns
operator -(Fixed4x4, Fixed4x4)
Subtracts two matrices element-wise.
public static Fixed4x4 operator -(Fixed4x4 lhs, Fixed4x4 rhs)
Parameters
Returns
operator -(Fixed4x4)
Negates the specified matrix by multiplying all its values by -1.
public static Fixed4x4 operator -(Fixed4x4 value)
Parameters
valueFixed4x4