Matrix Type
An immutable 4x4 transformation matrix. The matrix is represented in the following column-vector syntax form: M11 M21 M31 X41 M12 M22 M32 Y42 M13 M23 M33 Z43 M14 M24 M34 M44 Where X41, Y42 and Z43 refer to the translation part of the matrix. Note: Never use the struct default constructor Matrix() as it will create an invalid zero Matrix. Use Matrix.create or Matrix.createUnchecked instead.
Record fields
Record Field |
Description
|
Full Usage:
M11
Field type: float
|
|
Full Usage:
M12
Field type: float
|
|
Full Usage:
M13
Field type: float
|
|
Full Usage:
M14
Field type: float
|
|
Full Usage:
M21
Field type: float
|
|
Full Usage:
M22
Field type: float
|
|
Full Usage:
M23
Field type: float
|
|
Full Usage:
M24
Field type: float
|
|
Full Usage:
M31
Field type: float
|
|
Full Usage:
M32
Field type: float
|
|
Full Usage:
M33
Field type: float
|
|
Full Usage:
M34
Field type: float
|
|
Full Usage:
M44
Field type: float
|
|
Full Usage:
X41
Field type: float
|
|
Full Usage:
Y42
Field type: float
|
|
Full Usage:
Z43
Field type: float
|
|
Constructors
Constructor |
Description
|
Full Usage:
Matrix(m11, m21, m31, x41, m12, m22, m32, y42, m13, m23, m33, z43, m14, m24, m34, m44)
Parameters:
float
m21 : float
m31 : float
x41 : float
m12 : float
m22 : float
m32 : float
y42 : float
m13 : float
m23 : float
m33 : float
z43 : float
m14 : float
m24 : float
m34 : float
m44 : float
Returns: Matrix
|
Create a 4x4 Transformation Matrix. This Constructor takes arguments in row-major order, The matrix is represented in the following column-vector syntax form: M11 M21 M31 X41 M12 M22 M32 Y42 M13 M23 M33 Z43 M14 M24 M34 M44 Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
Instance members
Instance member |
Description
|
|
Returns the first column vector. M11, M12 and M13
|
|
Returns the second column vector. M21, M22 and M23
|
|
Returns the third column vector. M31, M32 and M33
|
Full Usage:
this.Determinant
Returns: float
|
The determinant of the Matrix. The Determinant describes the signed volume that a unit cube will have after the matrix was applied.
|
|
Inverts the matrix. If the determinant is zero the Matrix cannot be inverted. An Exception is raised.
|
Full Usage:
this.IsAffine
Returns: bool
|
Checks if the Matrix is an affine transformation. That means it does not do any projection. The fields m.M14, m.M24 and m.M34 must be 0.0 and m.M44 must be 1.0 or very close to it. Using an approximate tolerance of 1e-6.
|
Full Usage:
this.IsIdentity
Returns: bool
|
Checks if the Matrix is an identity matrix in the form of: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 Using an approximate tolerance of 1e-6.
|
Full Usage:
this.IsMirroring
Returns: bool
|
Returns if the Matrix is mirroring or reflection. It might also be rotating, translating or scaling, but not projecting. It must be affine and the determinate of the 3x3 part must be negative. Same as m.IsReflecting.
|
Full Usage:
this.IsOnlyTranslating
Returns: bool
|
Returns true if the Matrix is only translating. It might not be rotating, scaling, reflecting, or projecting.
|
Full Usage:
this.IsOrthogonal
Returns: bool
|
Returns if the Matrix is orthogonal. It might also be mirroring or scaling, but not shearing or projecting. It must be affine and the dot products of the three column vectors must be zero.
|
Full Usage:
this.IsProjecting
Returns: bool
|
Checks if the Matrix is an affine transformation. That means it does not do any projection. The fields m.M14, m.M24 and m.M34 must be 0.0 and m.M44 must be 1.0 or very close to it. Using an approximate tolerance of 1e-6.
|
Full Usage:
this.IsReflecting
Returns: bool
|
Returns if the Matrix is mirroring or reflection. It might also be rotating, translating or scaling, but not projecting. It must be affine and the determinate of the 3x3 part must be negative. Same as m.IsMirroring.
|
Full Usage:
this.IsScaling
Returns: bool
|
Returns if the Matrix is scaling. It might also be rotating, translating or reflecting, but not projecting. It must be affine and the 3 column vector must have a length other than one.
|
Full Usage:
this.IsTranslating
Returns: bool
|
Returns true if the Matrix is translating. It might also be rotating, scaling and reflecting, but not projecting.
|
Full Usage:
this.ToArrayByColumns
Returns: float[]
|
Returns the 16 elements column-major order: [| M11 M12 M13 M14 M21 M22 M23 M24 M31 M32 M33 M34 X41 Y42 Z43 M44 |] Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
Full Usage:
this.ToArrayByRows
Returns: float[]
|
Returns the 16 elements in row-major order: [| M11 M21 M31 X41 M12 M22 M32 Y42 M13 M23 M33 Z43 M14 M24 M34 M44 |] Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
|
Returns the translation or forth column vector. X41, Y42 and Z43
|
Static members
Static member |
Description
|
|
|
|
|
|
|
|
Creates a matrix from array of 16 elements in Column Major order: [| M11 M12 M13 M14 M21 M22 M23 M24 M31 M32 M33 M34 X41 Y42 Z43 M44 |] Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
Full Usage:
Matrix.createFromQuaternion quaternion
Parameters:
Quaternion
Returns: Matrix
|
|
|
Creates a matrix from array of 16 elements in Row Major order: [| M11 M21 M31 X41 M12 M22 M32 Y42 M13 M23 M33 Z43 M14 M24 M34 M44 |] Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
|
|
Full Usage:
Matrix.createPerspective (width, height, nearPlaneDistance, farPlaneDistance)
Parameters:
float
-
Width of the view volume at the near view plane.
height : float
-
Height of the view volume at the near view plane.
nearPlaneDistance : float
-
Distance to the near view plane.
farPlaneDistance : float
-
Distance to the far view plane.
Returns: Matrix
The perspective projection matrix.
|
Creates a perspective projection matrix from the given view volume dimensions.
|
|
|
|
|
|
|
|
Creates a rotation matrix around an axis at a given center point. axis — Rotation axis, a unit-vector. cen — The center point for the rotation. angleDegrees — Rotation angle in Degrees. Returns a positive rotation will be so clockwise looking in the direction of the axis vector.
|
|
Creates a rotation matrix around an axis at a given center point. axis — Rotation axis, a vector of any length but 0.0 cen — The center point for the rotation. angleDegrees — Rotation angle in Degrees. Returns a positive rotation will be so clockwise looking in the direction of the axis vector.
|
|
Creates a rotation transformation matrix around the X-axis by angle in Degrees (not Radians). angleDegrees — Rotation angle in Degrees. A positive rotation will be from Y towards Z-axis, so counter-clockwise looking onto Y-X Plane. The resulting matrix will be: 1 0 0 0 0 cos(θ) -sin(θ) 0 0 sin(θ) cos(θ) 0 0 0 0 1
|
|
Creates a rotation transformation matrix around the Y-axis by angle in Degrees (not Radians). angleDegrees — Rotation angle in Degrees. A positive rotation will be from Z towards X-axis, so counter-clockwise looking onto Z-X Plane. The resulting matrix will be: cos(θ) 0 sin(θ) 0 0 1 0 0 -sin(θ) 0 cos(θ) 0 0 0 0 1
|
|
Creates a rotation transformation matrix around the Z-axis by angle in Degrees (not Radians). angleDegrees — Rotation angle in Degrees. Returns a positive rotation will be from X toward Y-axis, so counter-clockwise looking onto X-Y plane. The resulting matrix will be: cos(θ) -sin(θ) 0 0 sin(θ) cos(θ) 0 0 0 0 1 0 0 0 0 1
|
|
Creates a scale transformation matrix: x - the amount to scale in the X-axis. y - the amount to scale in the Y-axis. z - the amount to scale in the Z-axis. The resulting matrix will be: x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1
|
Full Usage:
Matrix.createShear (xy, xz, yx, yz, zx, zy)
Parameters:
float
xz : float
yx : float
yz : float
zx : float
zy : float
Returns: Matrix
|
Creates a shear transformation matrix: xy - the amount to shear a X unit-vector a long Y-axis. xz - the amount to shear a X unit-vector a long Z-axis. yx - the amount to shear a Y unit-vector a long X-axis. yz - the amount to shear a Y unit-vector a long Z-axis. zx - the amount to shear a Z unit-vector a long X-axis. zy - the amount to shear a Z unit-vector a long Y-axis. The resulting matrix will be: 1, yx, zx, 0, xy, 1, zy, 0, xz, yz, 1, 0, 0, 0, 0, 1
|
|
|
|
|
Full Usage:
Matrix.createTranslation (x, y, z)
Parameters:
float
y : float
z : float
Returns: Matrix
|
Creates a translation matrix: x - the amount to translate in the X-axis. y - the amount to translate in the Y-axis. z - the amount to translate in the Z-axis. The resulting matrix will be: 1 0 0 x 0 1 0 y 0 0 1 z 0 0 0 1
|
|
Creates a rotation from one vectors direction to another vectors direction. If the tips of the two vectors unitized are closer than 1e-12 the identity matrix is returned. If the tips of the two vectors are almost exactly opposite, deviating less than 1e-6 from line (unitized), there is no valid unique 180 degree rotation that can be found, so an exception is raised.
|
|
Creates a rotation from one vectors direction to another vectors direction. If the tips of the two vectors are closer than 1e-12 the identity matrix is returned. If the tips of the two vectors are almost exactly opposite, deviating less than 1e-6 from line, there is no valid unique 180 degree rotation that can be found, so an exception is raised.
|
|
If the determinant of the Matrix. The determinant describes the volume that a unit cube will have have the matrix was applied.
|
|
|
|
Returns the identity matrix: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
|
|
|
|
|
|
Returns the 16 elements column-major order: [| M11 M12 M13 M14 M21 M22 M23 M24 M31 M32 M33 M34 X41 Y42 Z43 M44 |] Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
|
Returns the 16 elements in row-major order: [| M11 M21 M31 X41 M12 M22 M32 Y42 M13 M23 M33 Z43 M14 M24 M34 M44 |] Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
|