Mat4F

Description

struct Tinman.Core.Math.Vectors.Mat4F

A 4x4 matrix with 64-bit floating-point precision.

/                      \
|  M11  M12  M13  M14  |
|  M21  M22  M23  M24  |
|  M31  M32  M33  M34  |
|  M41  M42  M43  M44  |
\                      /

Public / Constants

Identity


public static readonly attribute Identity → (Mat4F)

The identity matrix.

Zero


public static readonly attribute Zero → (Mat4F)

The zero matrix.

Public / Constructors

From​Columns


[Pure]
public static method FromColumns → (4)

col1 in : Vec4F

The first column vector.

col2 in : Vec4F

The second column vector.

col3 in : Vec4F

The third column vector.

col4 in : Vec4F

The fourth column vector.

returns → Mat4F

The matrix.

Creates a new instance of Mat4F.

From​Rows


[Pure]
public static method FromRows → (4)

row1 in : Vec4F

The first row vector.

row2 in : Vec4F

The second row vector.

row3 in : Vec4F

The third row vector.

row4 in : Vec4F

The fourth row vector.

returns → Mat4F

The matrix.

Creates a new instance of Mat4F.

Look​At


[Pure]
public static method LookAt → (4)

origin in : Vec3F

The origin position.

target in : Vec3F

The look-at position.

up in : Vec3F

The up-direction vector.

rightHanded in : bool

true to create a right-handed coordinate system,
false to create a left-handed one.

returns → Mat4F

The transformation matrix.

Creates a look-at transformation matrix.

Mat4​F


public constructor Mat4F → (16)

m11 in : float32

Matrix component in first row, first column.

m12 in : float32

Matrix component in first row, second column.

m13 in : float32

Matrix component in first row, third column.

m14 in : float32

Matrix component in first row, fourth column.

m21 in : float32

Matrix component in second row, first column.

m22 in : float32

Matrix component in second row, second column.

m23 in : float32

Matrix component in second row, third column.

m24 in : float32

Matrix component in second row, fourth column.

m31 in : float32

Matrix component in third row, first column.

m32 in : float32

Matrix component in third row, second column.

m33 in : float32

Matrix component in third row, third column.

m34 in : float32

Matrix component in third row, fourth column.

m41 opt : float32 = 0

Matrix component in fourth row, first column.

m42 opt : float32 = 0

Matrix component in fourth row, second column.

m43 opt : float32 = 0

Matrix component in fourth row, third column.

m44 opt : float32 = 1

Matrix component in fourth row, fourth column.

Creates a new instance of Mat4F.

Orthographic


[Pure]
public static method Orthographic → (7)

left in : float32

The X-coordinate to map to -1.

right in : float32

The X-coordinate to map to +1.

top in : float32

The Y-coordinate to map to -1.

bottom in : float32

The Y-coordinate to map to +1.

zNear in : float32

The Z-coordinate to map to 0 resp. -1.

zFar in : float32

The Z-coordinate to map to +1.

nearAtZero in : bool

true to map zNear in to 0,
false to map zNear in to -1.

returns → Mat4F

The projection matrix.

Creates an orthographic projection matrix.

Perspective​Fov


[Pure]
public static method PerspectiveFov → (6)

fov in : float32

The field-of-view along the viewport Y-axis, in radians.

aspect in : float32

The viewport aspect ratio (width divided by height).

in : float32

Near clipping plane Z-value (will be mapped to 0 resp. -1 in clip-space; see nearAtZero in for details).

in : float32

Far clipping plane Z-value (will be mapped to 1 in clip-space).

nearAtZero in : bool

When true, the near clipping plane will be mapped to 0 in clip-space (e.g. Direct3D); when false it will be mapped to -1 (e.g. OpenGL).

rightHanded in : bool

Create projection matrix for a right-handed (true) or left-handed (false) coordinate system?

returns → Mat4F

The projection matrix.

Creates a perspective projection matrix.

Rotate

2 overloads


[Pure]
public static method Rotate1 → (2)

axis in : Vec3F

Unit-length rotation axis vector.

angle in : float32

The rotation angle, in radians.

returns → Mat4F

The resulting matrix.

Returns a rotation matrix (counter-clockwise around the given axis for right-handed coordinate system).


[Pure]
public static method Rotate2 → (4)

in : float32

X-component of unit-length rotation axis vector.

in : float32

Y-component of unit-length rotation axis vector.

in : float32

Z-component of unit-length rotation axis vector.

angle in : float32

The rotation angle, in radians.

returns → Mat4F

The resulting matrix.

Returns a rotation matrix (counter-clockwise around the given axis for right-handed coordinate system).

Rotate​X


[Pure]
public static method RotateX → (1)

angle in : float32

The rotation angle, in radians.

returns → Mat4F

The resulting matrix.

Returns a rotation matrix (counter-clockwise around X-axis for right-handed coordinate system).

Rotate​Y


[Pure]
public static method RotateY → (1)

angle in : float32

The rotation angle, in radians.

returns → Mat4F

The resulting matrix.

Returns a rotation matrix (counter-clockwise around Y-axis for right-handed coordinate system).

Rotate​Z


[Pure]
public static method RotateZ → (1)

angle in : float32

The rotation angle, in radians.

returns → Mat4F

The resulting matrix.

Returns a rotation matrix (counter-clockwise around Z-axis for right-handed coordinate system).

Scale

3 overloads


[Pure]
public static method Scale1 → (1)

in : float32

The scale factor.

returns → Mat4F

The resulting matrix.

Returns a scaling matrix.


[Pure]
public static method Scale2 → (1)

in : Vec4F

The scale factors.

returns → Mat4F

The resulting matrix.

Returns a scaling matrix.


[Pure]
public static method Scale3 → (4)

fx in : float32

The scale factor along the X-axis.

fy in : float32

The scale factor along the Y-axis.

fz in : float32

The scale factor along the Z-axis.

fw in : float32

The scale factor along the W-axis.

returns → Mat4F

The resulting matrix.

Returns a scaling matrix.

Translate

2 overloads


[Pure]
public static method Translate1 → (1)

in : Vec3F

The translation vector.

returns → Mat4F

The translation matrix.

Returns a translation matrix.


[Pure]
public static method Translate2 → (3)

in : float32

X-component of translation vector.

in : float32

Y-component of translation vector.

in : float32

Z-component of translation vector.

returns → Mat4F

The translation matrix.

Returns a translation matrix.

Warp


[Pure]
public static method Warp → (6)

a0 in : Vec3F

First vertex of source triangle.

b0 in : Vec3F

Second vertex of source triangle.

c0 in : Vec3F

Third vertex of source triangle.

a1 in : Vec3F

First vertex of target triangle.

b1 in : Vec3F

Second vertex of target triangle.

c1 in : Vec3F

Third vertex of target triangle.

returns → Mat4F

The homogeneous 3D warp matrix.

Computes an invertible 3D homogeneous warp matrix that transforms the given source triangle onto the specified target triangle.

The fourth row of the returned matrix will always be (0,0,0,1), so it is not necessary to perform the homogeneous divide. Also all elements along the main diagonal will be 1.

Public / Methods

Equals​Almost


[Pure]
public method EqualsAlmost → (1)

other in : Mat4F

The other matrix.

returns → bool

true if both matrices are similar, false if they are not.

Checks if this matrix and the given one are similar but necessarily equal.

See also

Maths.Similar1

Get​Column


[Pure]
public method GetColumn → (1)

index in : int32

The zero-based column index.

returns → Vec4F

The column vector.

Returns a column vector.

Get​Row


[Pure]
public method GetRow → (1)

index in : int32

The zero-based row index.

returns → Vec4F

The row vector.

Returns a row vector.

Lerp


[Pure]
public method Lerp → (2)

other in : Mat4F

The other matrix.

factor in : float32

The interpolation factor (0: this, 1: other in).

returns → Mat4F

The resulting matrix.

Performs a component-wise linear interpolation between this matrix and the given one.

Mul


[Pure]
public method Mul → (1)

in : Mat4F

The matrix.

returns → Mat4F

The resulting matrix.

Multiplies this matrix (left-side) with the given one (right-side): result = this * m.

Mul3

2 overloads


[Pure]
public method Mul31 → (2)

in : Vec3F

The vector.

in : float32

The W-component to assume.

returns → Vec3F

The resulting vector, scaled by 1/result.W.

Multiplies this matrix (left-side) with the given homogeneous 3D vector (right-side): result = this * v.


[Pure]
public method Mul32 → (4)

in : float32

X-component of vector.

in : float32

Y-component of vector.

in : float32

Z-component of vector.

in : float32

The W-component to assume.

returns → Vec3F

The resulting vector, scaled by 1/result.W.

Multiplies this matrix (left-side) with the given homogeneous 3D vector (right-side): result = this * v.

Mul4

2 overloads


[Pure]
public method Mul41 → (1)

in : Vec4F

The vector.

returns → Vec4F

The resulting vector.

Multiplies this matrix (left-side) with the given 4D vector (right-side): result = this * v.


[Pure]
public method Mul42 → (4)

in : float32

X-component of vector.

in : float32

Y-component of vector.

in : float32

Z-component of vector.

in : float32

W-component of vector.

returns → Vec4F

The resulting vector.

Multiplies this matrix (left-side) with the given 4D vector (right-side): result = this * v.

Perspective​Ray


[Pure]
public method PerspectiveRay → (6)

translation in : Vec3F

The translation components, if they have been omitted in the view projection, otherwise Vec3D.Zero.

pixelX in : float32

Pixel X-coordinate (see remarks).

pixelY in : float32

Pixel Y-coordinate (see remarks).

screenWidth in : int32

Screen width, in pixels.

screenHeight in : int32

Screen height, in pixels.

nearAtZero in : bool

When true, the near clipping plane will be mapped to 0 in clip-space (e.g. Direct3D); when false it will be mapped to -1 (e.g. OpenGL).

returns → Ray

The ray

Computes a ray for a screen-pixel.

This matrix must be the inverse of a combined world-view-projection matrix (for example, PerspectiveFov). The pixel coordinates (0,0) refer to the top-left corner of the top-left screen pixel. The pixel coordinates (w,h) refer to the bottom-right corner of the bottom-right screen pixel (where w and h are the screen width resp. height). If you want to cast rays for pixel centers, you have to add an offset of 0.5 to the pixel coordinates.

To​Array


public method ToArray → (4)

values in : float32 [ ]

[not-null]
The output array.

offset opt : int32 = 0

Offset into values in to top-left matrix element.

strideRow opt : int32 = 4

Array index distance between matrix rows.

strideCol opt : int32 = 1

Array index distance between matrix columns.

Copies matrix elements to the given array.

The method uses the following indexing scheme to write values to values in:

values[offset + (row - 1) * strideRow + (col - 1) * strideCol := matrix[row, col];

where row and col depict the matrix row and column number (starting at 1).

To​String

2 overloads


[Pure]
public method ToString2 → (1)

flags in : FormatFlags

The format flags to use.

returns → string

The string representation.

Returns the string representation of this matrix.

See also

Vec4F.ToString2

Public / Attributes

Determinant


public attribute Determinant → (get)

value : float32

The determinant value.

Returns the determinant of this matrix.

Inverse


public attribute Inverse → (get)

value : Mat4F

The inverse matrix.

Returns the inverse of this matrix.

M11


public readonly attribute M11 → (float32)

Matrix component in first row, first column.

M12


public readonly attribute M12 → (float32)

Matrix component in first row, second column.

M13


public readonly attribute M13 → (float32)

Matrix component in first row, third column.

M14


public readonly attribute M14 → (float32)

Matrix component in first row, fourth column.

M21


public readonly attribute M21 → (float32)

Matrix component in second row, first column.

M22


public readonly attribute M22 → (float32)

Matrix component in second row, second column.

M23


public readonly attribute M23 → (float32)

Matrix component in second row, third column.

M24


public readonly attribute M24 → (float32)

Matrix component in second row, fourth column.

M31


public readonly attribute M31 → (float32)

Matrix component in third row, first column.

M32


public readonly attribute M32 → (float32)

Matrix component in third row, second column.

M33


public readonly attribute M33 → (float32)

Matrix component in third row, third column.

M34


public readonly attribute M34 → (float32)

Matrix component in third row, fourth column.

M41


public readonly attribute M41 → (float32)

Matrix component in fourth row, first column.

M42


public readonly attribute M42 → (float32)

Matrix component in fourth row, second column.

M43


public readonly attribute M43 → (float32)

Matrix component in fourth row, third column.

M44


public readonly attribute M44 → (float32)

Matrix component in fourth row, fourth column.

Transpose


public attribute Transpose → (get)

value : Mat4F

The transposed matrix.

Returns the transpose of this matrix.

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializer<Mat4F>)

The serialization helper object for values of Mat4F.