Matrix4x4
La référence est en anglais : elle est générée à partir des commentaires du code, écrits en anglais.
public struct Matrix4x4 : IEquatable<Matrix4x4>, IFormattableNamespace NodeWorld.Flux.
A 4x4 matrix, mRC = row R, column C, stored column after column (as Unity's). Points are column vectors: M * p.
Fields
m00
public float m00The value at row 0, column 0.
m10
public float m10The value at row 1, column 0.
m20
public float m20The value at row 2, column 0.
m30
public float m30The value at row 3, column 0.
m01
public float m01The value at row 0, column 1.
m11
public float m11The value at row 1, column 1.
m21
public float m21The value at row 2, column 1.
m31
public float m31The value at row 3, column 1.
m02
public float m02The value at row 0, column 2.
m12
public float m12The value at row 1, column 2.
m22
public float m22The value at row 2, column 2.
m32
public float m32The value at row 3, column 2.
m03
public float m03The value at row 0, column 3.
m13
public float m13The value at row 1, column 3.
m23
public float m23The value at row 2, column 3.
m33
public float m33The value at row 3, column 3.
Constructors
Matrix4x4
public Matrix4x4(Vector4 column0, Vector4 column1, Vector4 column2, Vector4 column3)The matrix of these four columns.
Properties
this[]
public float this[int row, int column] { get; set; }The value at row and column (0 to 3).
public float this[int index] { get; set; }The value at index 0 to 15, column after column (index = row + column * 4).
zero
public static Matrix4x4 zero { get; }Every value 0.
identity
public static Matrix4x4 identity { get; }The identity matrix: 1 on the diagonal.
isIdentity
public bool isIdentity { get; }The matrix is the identity.
transpose
public Matrix4x4 transpose { get; }The matrix with rows and columns swapped.
determinant
public float determinant { get; }The determinant.
inverse
public Matrix4x4 inverse { get; }The inverse (cofactors / determinant); the zero matrix if the matrix is singular.
rotation
public Quaternion rotation { get; }The rotation part (the upper 3x3 without its scale).
lossyScale
public Vector3 lossyScale { get; }The scale of the upper 3x3 (length of its columns, negative if the matrix mirrors).
Methods
GetColumn
public Vector4 GetColumn(int index)The column index (0 to 3).
GetRow
public Vector4 GetRow(int index)The row index (0 to 3).
SetColumn
public void SetColumn(int index, Vector4 column)Sets the column index (0 to 3).
SetRow
public void SetRow(int index, Vector4 row)Sets the row index (0 to 3).
GetPosition
public Vector3 GetPosition()The translation part: m03, m13, m23.
MultiplyPoint
public Vector3 MultiplyPoint(Vector3 point)Transforms a point, with the projective divide.
MultiplyPoint3x4
public Vector3 MultiplyPoint3x4(Vector3 point)Transforms a point by an affine matrix (no projective divide).
MultiplyVector
public Vector3 MultiplyVector(Vector3 vector)Transforms a direction (rotation and scale only).
Transpose
public static Matrix4x4 Transpose(Matrix4x4 m)m with rows and columns swapped.
Determinant
public static float Determinant(Matrix4x4 m)The determinant of m.
Inverse
public static Matrix4x4 Inverse(Matrix4x4 m)The inverse of m; the zero matrix if m is singular.
TRS
public static Matrix4x4 TRS(Vector3 pos, Quaternion q, Vector3 s)Translation, rotation and scale: T * R * S.
SetTRS
public void SetTRS(Vector3 pos, Quaternion q, Vector3 s)Makes it TRS(pos, q, s).
Translate
public static Matrix4x4 Translate(Vector3 vector)A translation matrix.
Rotate
public static Matrix4x4 Rotate(Quaternion q)A rotation matrix.
Scale
public static Matrix4x4 Scale(Vector3 vector)A scale matrix.
Perspective
public static Matrix4x4 Perspective(float fov, float aspect, float zNear, float zFar)Perspective projection (clip space z from -1 to 1, as OpenGL and Unity's matrices).
Ortho
public static Matrix4x4 Ortho(float left, float right, float bottom, float top, float zNear, float zFar)Orthographic projection (clip space z from -1 to 1, as Perspective).
LookAt
public static Matrix4x4 LookAt(Vector3 from, Vector3 to, Vector3 up)A matrix placing an object at "from", its forward (z) towards "to".
Equals
public bool Equals(Matrix4x4 other)The sixteen values are exactly equal.
public override bool Equals(object other)other is a matrix with exactly the same values.
GetHashCode
public override int GetHashCode()A hash of the values.
ToString
public override string ToString()The four rows, values separated by tabs, with 5 decimals.
public string ToString(string format)The same text with the numbers in format.
public string ToString(string format, IFormatProvider formatProvider)The same text with the numbers in format (F5 when empty) and formatProvider (the invariant culture when null).
Operators
operator *
public static Matrix4x4 operator *(Matrix4x4 lhs, Matrix4x4 rhs)The product lhs * rhs: rhs applies first.
public static Vector4 operator *(Matrix4x4 lhs, Vector4 v)The matrix times the column vector v.
operator ==
public static bool operator ==(Matrix4x4 lhs, Matrix4x4 rhs)Every column equal (as Vector4's ==).
operator !=
public static bool operator !=(Matrix4x4 lhs, Matrix4x4 rhs)The matrices differ (see ==).
