public readonly struct Matrix4x4A 4×4 transform: **row-vector convention with row-major storage**, translation in M41..M43, composing left to right. world = local * parent, and a point is transformed as v * M.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is ADR-003's convention and it is not negotiable per-call-site: it is the same one the shader side uses, and the derivation showing that a ColMajor-decorated shader matrix and this row-major storage are the same sixty-four bytes is in docs/plan/07 § E. Read Conventions.md before changing anything here.
Depth is reverse-Z over [0, 1]: the projections map the near plane to 1 and the far plane to 0.
Fields and properties (28)
public const int ComponentCountNumber of components.
public readonly float M11Row 1, column 1.
public readonly float M12Row 1, column 2.
public readonly float M13Row 1, column 3.
public readonly float M14Row 1, column 4.
public readonly float M21Row 2, column 1.
public readonly float M22Row 2, column 2.
public readonly float M23Row 2, column 3.
public readonly float M24Row 2, column 4.
public readonly float M31Row 3, column 1.
public readonly float M32Row 3, column 2.
public readonly float M33Row 3, column 3.
public readonly float M34Row 3, column 4.
public readonly float M41Row 4, column 1 — the X translation.
public readonly float M42Row 4, column 2 — the Y translation.
public readonly float M43Row 4, column 3 — the Z translation.
public readonly float M44Row 4, column 4.
public static Matrix4x4 IdentityThe transform that does nothing.
public Vector4 Row1The first row.
public Vector4 Row2The second row.
public Vector4 Row3The third row.
public Vector4 Row4The fourth row, whose XYZ is the translation.
public Vector3 TranslationThe translation the matrix applies.
public Vector3 RightThe X axis of the transformed frame — the first row's XYZ.
public Vector3 UpThe Y axis of the transformed frame — the second row's XYZ.
public Vector3 ForwardThe forward direction of the transformed frame: the negated third row, because right-handed means forward is −Z.
public float this[int row, int column]The element at , , one-based.
public bool IsIdentityWhether this is the identity, to within the default tolerance.
Methods (40)
public Matrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)Builds a matrix from its sixteen elements, in row-major order.
public Matrix4x4(Vector4 row1, Vector4 row2, Vector4 row3, Vector4 row4)Builds a matrix from its four rows.
public ReadOnlySpan<float> AsSpan()The elements in row-major order. Valid as long as the matrix it came from.
public static Matrix4x4 FromTranslation(Vector3 translation)Moves by .
public static Matrix4x4 FromScale(Vector3 scale)Scales each axis independently.
public static Matrix4x4 FromUniformScale(float scale)Scales every axis equally.
public static Matrix4x4 FromRotationX(float radians)Rotates about the X axis, counter-clockwise looking down +X toward the origin.
public static Matrix4x4 FromRotationY(float radians)Rotates about the Y axis, counter-clockwise looking down +Y toward the origin.
public static Matrix4x4 FromRotationZ(float radians)Rotates about the Z axis, counter-clockwise looking down +Z toward the origin.
public static Matrix4x4 FromQuaternion(Quaternion rotation)The rotation a quaternion describes, as a matrix.
public static Matrix4x4 Compose(Vector3 scale, Quaternion rotation, Vector3 translation)The single transform that scales, then rotates, then translates — the order every scene graph wants and the one it is easy to get backwards by composing by hand.
public static bool Decompose(in Matrix4x4 matrix, out Vector3 scale, out Quaternion rotation, out Vector3 translation)Splits an affine transform back into scale, rotation and translation.
public static Quaternion ToQuaternion(in Matrix4x4 matrix)The rotation part of a matrix, as a quaternion. Assumes no scale.
public static Matrix4x4 LookAt(Vector3 eye, Vector3 target, Vector3 up)A right-handed view matrix: the transform from world space into the camera's space.
public static Matrix4x4 PerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)A right-handed perspective projection with **reverse-Z** depth: the near plane maps to 1 and the far plane to 0.
public static Matrix4x4 PerspectiveFieldOfViewInfinite(float fieldOfView, float aspectRatio, float nearPlane)A right-handed reverse-Z perspective projection with no far plane. The far plane's only purpose under reverse-Z is to bound the depth range, and pushing it to infinity costs nothing in precision — so the choice is free and one fewer thing to tune.
public static Matrix4x4 Orthographic(float width, float height, float nearPlane, float farPlane)A right-handed orthographic projection with reverse-Z depth, centred on the origin.
public static Matrix4x4 OrthographicOffCenter(float left, float right, float bottom, float top, float nearPlane, float farPlane)A right-handed orthographic projection with reverse-Z depth and an arbitrary rectangle, for shadow cascades and UI.
public static Matrix4x4 Multiply(in Matrix4x4 left, in Matrix4x4 right)Composes two transforms: apply , then .
public static Matrix4x4 Transpose(in Matrix4x4 matrix)Transposes the matrix.
public static float Determinant(in Matrix4x4 matrix)The determinant — the signed volume scale the transform applies.
public static bool Invert(in Matrix4x4 matrix, out Matrix4x4 result)Inverts the matrix.
public static Vector3 TransformPosition(Vector3 position, in Matrix4x4 matrix)Transforms a point, applying the translation.
public static Vector3 TransformDirection(Vector3 direction, in Matrix4x4 matrix)Transforms a direction, ignoring the translation. For normals under a non-uniform scale, transform by the inverse transpose instead — see Normal.
public static Vector4 TransformVector4(Vector4 value, in Matrix4x4 matrix)Transforms a homogeneous vector, without the perspective divide.
public static void TransformPositions(ReadOnlySpan<Vector3> source, in Matrix4x4 matrix, Span<Vector3> destination)Transforms a run of points in one call. Culling and skinning do this a million times a frame, and hoisting the matrix out of the loop is most of why this exists.
public static void TransformDirections(ReadOnlySpan<Vector3> source, in Matrix4x4 matrix, Span<Vector3> destination)Transforms a run of directions in one call, ignoring the translation.
public static bool NearEqual(in Matrix4x4 left, in Matrix4x4 right, float tolerance = 1E-06)Whether two matrices agree to within a tolerance, element by element.
public static Matrix4x4 operator *(Matrix4x4 left, Matrix4x4 right)public static Vector4 operator *(Vector4 value, Matrix4x4 matrix)Transforms a row vector: v * M, the convention this library uses throughout.
public static bool operator ==(Matrix4x4 left, Matrix4x4 right)Exact element-wise equality, IEEE semantics. See NearEqual.
public static bool operator !=(Matrix4x4 left, Matrix4x4 right)The negation of op_Equality.
public static implicit operator Matrix4x4(Matrix4x4 value)Converts to the BCL matrix. A reinterpretation, not a transpose: the BCL is also row-major with the translation in M41..M43.
public static implicit operator Matrix4x4(Matrix4x4 value)Converts from the BCL matrix, which has the same layout.
public bool Equals(Matrix4x4 other)Indicates whether the current object is equal to another object of the same type.
public override bool Equals(object? obj)Indicates whether this instance and a specified object are equal.
public override int GetHashCode()Returns the hash code for this instance.
public override string ToString()Returns the fully qualified type name of this instance.
public string ToString(string? format, IFormatProvider? formatProvider)Formats the value of the current instance using the specified format.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider? provider = null)Tries to format the value of the current instance into the provided span of characters.
Used by (319, showing 40)
- ArenaThirdPersonShooter
- ArenaFrameThirdPersonShooter
- DrawConstantsPbrShowcase
- FrameDocumentTestsThirdPersonShooter.Frame.Tests
- PbrShowcaseGamePbrShowcase
- ViewConstantsPbrShowcase
- VirtualGeometryGameVirtualGeometry
- BulkTransformBenchmarksVixen.Benchmarks.Math
- MatrixBenchmarksVixen.Benchmarks.Math
- RigsVixen.Benchmarks.Animation
- AlgebraicPropertyTestsVixen.Core.Mathematics.Tests
- AmbientOcclusionRendererVixen.Rendering.PostFx
- AnimatorVixen.Animation
- AnimatorTestsVixen.Animation.Tests
- AudioEventSystemTestsVixen.Audio.Tests
- AudioSystemVixen.Audio
- AudioSystemTestsVixen.Audio.Tests
- BindlessFrameTestsVixen.Rendering.Tests
- BodyVariationVixen.Animation
- BoneTransformVixen.Animation
- BoneTransformTestsVixen.Animation.Tests
- BoundingBoxVixen.Core.Mathematics
- BoundingFrustumVixen.Core.Mathematics
- BoundingSphereVixen.Core.Mathematics
- BufferTransferDeviceTestsVixen.Graphics.Golden.Tests
- CameraDirectorSystemVixen.Engine
- CameraDirectorTestsVixen.Engine.Tests
- CameraExtractionSystemVixen.Rendering
- CameraExtractionTestsVixen.Rendering.Tests
- CameraMathVixen.Engine
- ClusterAttributeTestsVixen.Rendering.Tests
- ClusterCullingDeviceTestsVixen.Graphics.Golden.Tests
- ClusterRasterConstantsVixen.Rendering
- ClusterRasterKeysVixen.Rendering
- ClusterResolveTestsVixen.Rendering.Tests
- ClusterSoftwareRasterConstantsVixen.Rendering
- ClusterSoftwareRasterKeysVixen.Rendering
- ClusterTraversalAcceptsTestsVixen.Rendering.Tests
- ClusterTraversalGroupTestsVixen.Rendering.Tests
- ClusteredLightingTestsVixen.Rendering.Tests