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. So (M11, M21, M31, X41, M12, ...) The matrix is represented in the following column-vector syntax form:
Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
Instance members
| Instance member |
Description
|
Full Usage:
this.AsFSharpCode
Returns: string
|
Format Matrix into an F# code string that can be used to recreate the matrix. The output matches the constructor's row-major parameter order.
|
Full Usage:
this.AsString
Returns: string
|
Nicely formats the Matrix to a Grid of 4x4 (without field names) the following column-vector syntax form:
Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
|
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:
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 a projection transformation. That means it does perform projection (perspective divide). Returns true if at least one of the fields m.M14, m.M24, m.M34 is not 0.0 or m.M44 is not 1.0. 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 at least one of the 3 column vectors must have a squared length other than 1.0.
|
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:
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:
Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
|
Returns the translation or fourth column vector. X41, Y42 and Z43.
|
Static members
| Static member |
Description
|
Multiplies a Matrix with a 3D unit-vector. Since a 3D vector represents a direction or translation in space, but not a location, the implicit 4th dimension is 0.0 so that all translations are ignored. (Homogeneous Vector)
|
|
Multiplies (or applies) a Matrix to a 3D vector. Since a 3D vector represents a direction or translation in space, but not a location, the implicit 4th dimension is 0.0 so that all translations are ignored. (Homogeneous Vector)
|
|
|
|
|
|
|
|
Full Usage:
Matrix.createFromColumMajorArray xs
Parameters:
float[]
-
Array of 16 float elements in column-major order.
Returns: Matrix
|
Creates a matrix from array of 16 elements in Column Major order:
Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
Full Usage:
Matrix.createFromQuaternion quaternion
Parameters:
Quaternion
-
The quaternion representing the rotation.
Returns: Matrix
|
Create Matrix from Quaternion.
|
Full Usage:
Matrix.createFromRowMajorArray xs
Parameters:
float[]
-
Array of 16 float elements in row-major order.
Returns: Matrix
|
Creates a matrix from array of 16 elements in Row Major order:
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. Must be greater than 0.0.
farPlaneDistance : float
-
Distance to the far view plane. Must be greater than 0.0 and greater than nearPlaneDistance.
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. A positive angle rotates counter-clockwise when the axis vector is pointing towards the observer (right-hand rule).
|
|
Creates a rotation matrix around an axis at a given center point. A positive angle rotates counter-clockwise when the axis vector is pointing towards the observer (right-hand rule).
|
Full Usage:
Matrix.createRotationX angleDegrees
Parameters:
float
-
Rotation angle in Degrees.
Returns: Matrix
|
Creates a rotation transformation matrix around the X-axis by angle in Degrees (not Radians). A positive rotation will be from Y towards Z-axis, so counter-clockwise the X-axis vector is pointing towards the observer. The resulting matrix will be:
val cos: value: 'T -> 'T (requires member Cos)
val sin: value: 'T -> 'T (requires member Sin)
|
Full Usage:
Matrix.createRotationY angleDegrees
Parameters:
float
-
Rotation angle in Degrees.
Returns: Matrix
|
Creates a rotation transformation matrix around the Y-axis by angle in Degrees (not Radians). A positive rotation will be from Z towards X-axis, so counter-clockwise the Y-axis vector is pointing towards the observer. The resulting matrix will be:
val cos: value: 'T -> 'T (requires member Cos)
val sin: value: 'T -> 'T (requires member Sin)
|
Full Usage:
Matrix.createRotationZ angleDegrees
Parameters:
float
-
Rotation angle in Degrees.
Returns: Matrix
|
Creates a rotation transformation matrix around the Z-axis by angle in Degrees (not Radians). A positive rotation will be from X toward Y-axis, so counter-clockwise the Z-axis vector is pointing towards the observer. The resulting matrix will be:
val cos: value: 'T -> 'T (requires member Cos)
val sin: value: 'T -> 'T (requires member Sin)
|
Full Usage:
Matrix.createScale (x, y, z)
Parameters:
float
-
The amount to scale in the X-axis.
y : float
-
The amount to scale in the Y-axis.
z : float
-
The amount to scale in the Z-axis.
Returns: Matrix
|
Creates a scale transformation matrix. The resulting matrix will be:
|
Full Usage:
Matrix.createShear (xy, xz, yx, yz, zx, zy)
Parameters:
float
-
The amount to shear the Y component when moving along the X-axis.
xz : float
-
The amount to shear the Z component when moving along the X-axis.
yx : float
-
The amount to shear the X component when moving along the Y-axis.
yz : float
-
The amount to shear the Z component when moving along the Y-axis.
zx : float
-
The amount to shear the X component when moving along the Z-axis.
zy : float
-
The amount to shear the Y component when moving along the Z-axis.
Returns: Matrix
|
Creates a shear transformation matrix. The resulting matrix will be:
|
|
|
|
|
Full Usage:
Matrix.createTranslation (x, y, z)
Parameters:
float
-
The amount to translate in the X-axis.
y : float
-
The amount to translate in the Y-axis.
z : float
-
The amount to translate in the Z-axis.
Returns: Matrix
|
Creates a translation matrix. The resulting matrix will be:
|
|
Creates a rotation from one vectors direction to another vectors direction. Does NOT do any scaling. Ignores the length of the input vectors and unitizes them first. If the tips of the two unitized vectors have a distance less than 1e-12 the identity matrix is returned. If the tips of the two vectors are almost exactly opposite, that is if tips of the two vectors are less than 1e-12 apart when summed, there is no valid unique 180 degree rotation that can be found, so an exception is raised. Fails if either vector is too short (length less than 1e-6).
|
|
Creates a rotation from one unit-vectors direction to another unit-vectors direction. If the tips of the two unitized vectors have a distance less than 1e-12 the identity matrix is returned. If the tips of the two vectors are almost exactly opposite, that is if tips of the two vectors are less than 1e-12 apart when summed, there is no valid unique 180 degree rotation that can be found, so an exception is raised.
|
Full Usage:
Matrix.determinant m
Parameters:
Matrix
-
The matrix.
Returns: float
Modifiers: inline |
The determinant of the Matrix. The determinant describes the signed volume that a unit cube will have after the matrix was applied.
|
|
Checks if two matrices are equal within tolerance. By comparing the fields M11 to M44 each with the given tolerance. Use a tolerance of 0.0 to check for an exact match.
|
|
Returns the identity matrix:
|
|
|
|
|
Full Usage:
Matrix.toArrayByColumns m
Parameters:
Matrix
-
The matrix.
Returns: float[]
Modifiers: inline |
Returns the 16 elements column-major order:
Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
Full Usage:
Matrix.toArrayByRows m
Parameters:
Matrix
-
The matrix.
Returns: float[]
Modifiers: inline |
Returns the 16 elements in row-major order:
Where X41, Y42 and Z43 refer to the translation part of the matrix.
|
|
Euclid