Mat3D

Description

struct Tinman.Core.Math.Vectors.Mat3D

A 3x3 matrix with 64-bit floating-point precision.

/                 \
|  M11  M12  M13  |
|  M21  M22  M23  |
|  M31  M32  M33  |
\                 /

Public / Constants

Identity


public static readonly attribute Identity → (Mat3D)

The identity matrix.

Zero


public static readonly attribute Zero → (Mat3D)

The zero matrix.

Public / Constructors

From​Columns


[Pure]
public static method FromColumns → (3)

col1 in : Vec3D

The first column vector.

col2 in : Vec3D

The second column vector.

col3 in : Vec3D

The third column vector.

returns → Mat3D

The matrix.

Creates a new instance of Mat3D.

From​Rows


[Pure]
public static method FromRows → (3)

row1 in : Vec3D

The first row vector.

row2 in : Vec3D

The second row vector.

row3 in : Vec3D

The third row vector.

returns → Mat3D

The matrix.

Creates a new instance of Mat3D.

Mat3​D


public constructor Mat3D → (9)

m11 in : float64

Matrix component in first row, first column.

m12 in : float64

Matrix component in first row, second column.

m13 in : float64

Matrix component in first row, third column.

m21 in : float64

Matrix component in second row, first column.

m22 in : float64

Matrix component in second row, second column.

m23 in : float64

Matrix component in second row, third column.

m31 opt : float64 = 0

Matrix component in third row, first column.

m32 opt : float64 = 0

Matrix component in third row, second column.

m33 opt : float64 = 1

Matrix component in third row, third column.

Creates a new instance of Mat3D.

Rotate

2 overloads


[Pure]
public static method Rotate1 → (2)

axis in : Vec3D

Unit-length rotation axis vector.

angle in : float64

The rotation angle, in radians.

returns → Mat3D

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 : float64

X-component of unit-length rotation axis vector.

in : float64

Y-component of unit-length rotation axis vector.

in : float64

Z-component of unit-length rotation axis vector.

angle in : float64

The rotation angle, in radians.

returns → Mat3D

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 : float64

The rotation angle, in radians.

returns → Mat3D

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 : float64

The rotation angle, in radians.

returns → Mat3D

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 : float64

The rotation angle, in radians.

returns → Mat3D

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 : float64

The scale factor.

returns → Mat3D

The resulting matrix.

Returns a scaling matrix.


[Pure]
public static method Scale2 → (1)

in : Vec3D

The scale factors.

returns → Mat3D

The resulting matrix.

Returns a scaling matrix.


[Pure]
public static method Scale3 → (3)

fx in : float64

The scale factor along the X-axis.

fy in : float64

The scale factor along the Y-axis.

fz in : float64

The scale factor along the Z-axis.

returns → Mat3D

The resulting matrix.

Returns a scaling matrix.

Tangent​Space


[Pure]
public static method TangentSpace → (4)

in : Vec3D

The vector in object space to map to the tangent space X-axis.

in : Vec3D

The vector in object space to map to the tangent space Y-axis.

in : Vec3D

The vector in object space to map to the tangent space Z-axis.

orthogonalize opt : int32 = 0

Depicts how to orthogonalize the tangent space vectors:

  • 0: Skip orthogonalization, only normalize to unit-length.

  • 1: in, in, in

  • 2: in, in, in

  • 3: in, in, in

  • 4: in, in, in

  • 5: in, in, in

  • 6: in, in, in

The first tangent space basis vector will be normalized to unit-length. The second and third tangent space basis vectors will be orthogonalized using the Gram-Schmidt algorithm and then normalized to unit-length (except 0 is given).

returns → Mat3D

The resulting matrix:

    / x'.x  y'.x  z'.x \
M = | x'.y  y'.y  z'.y |
    \ x'.z  y'.z  z'.z /

where x', y' and z' are the normalized and orthogonalized tangent space basis vectors.

Returns a matrix that transforms from tangent space to object space.

Translate

2 overloads


[Pure]
public static method Translate1 → (1)

in : Vec2D

The 2D translation vector.

returns → Mat3D

The resulting matrix.

Returns a homogeneous 2D translation matrix.


[Pure]
public static method Translate2 → (2)

in : float64

X-component of translation vector.

in : float64

Y-component of translation vector.

returns → Mat3D

The resulting matrix.

Returns a homogeneous 2D translation matrix.

Warp


[Pure]
public static method Warp → (4)

in : Vec2D

First vertex of convex quadrilateral.

in : Vec2D

Second vertex of convex quadrilateral.

in : Vec2D

Third vertex of convex quadrilateral.

in : Vec2D

Fourth vertex of convex quadrilateral.

returns → Mat3D

The homogeneous 2D warp matrix.

Computes a 2D homogeneous warp matrix that transforms the unit square into a convex quadrilateral.

The unit square is defined as follows:

A ---- B     A := (0|0)
|      |     B := (1|0)
|      |     C := (1|1)
D ---- C     D := (0|1)

Use the inverse warp matrix to transform vertices to the unit square. Combine two warp matrices to transform from one quadrilateral to another.

Public / Methods

Equals​Almost


[Pure]
public method EqualsAlmost → (1)

other in : Mat3D

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.Similar2

Get​Column


[Pure]
public method GetColumn → (1)

index in : int32

The zero-based column index.

returns → Vec3D

The column vector.

Returns a column vector.

Get​Row


[Pure]
public method GetRow → (1)

index in : int32

The zero-based row index.

returns → Vec3D

The row vector.

Returns a row vector.

Mul


[Pure]
public method Mul → (1)

in : Mat3D

The matrix.

returns → Mat3D

The resulting matrix.

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

Mul2

3 overloads


[Pure]
public method Mul21 → (2)

in : Vec2D

The vector.

in : float64

The W-component to assume.

returns → Vec2D

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

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


[Pure]
public method Mul22 → (3)

in : float64

X-component of vector.

in : float64

Y-component of vector.

in : float64

The W-component to assume.

returns → Vec2D

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

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


[Pure]
public method Mul23 → (4)

in : float64

X-component of vector.

in : float64

Y-component of vector.

dx out : Vec2D

The partial derivative vector along the X-axis.

dy out : Vec2D

The partial derivative vector along the Y-axis.

returns → Vec2D

The resulting point.

Multiplies this matrix (left-side) with the given 2D point (right-side), assuming a homogeneous W-coordinate of 1 and computes the partial derivatives: result = this * v.

Mul3

2 overloads


[Pure]
public method Mul31 → (1)

in : Vec3D

The vector.

returns → Vec3D

The resulting vector.

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


[Pure]
public method Mul32 → (3)

in : float64

X-component of vector.

in : float64

Y-component of vector.

in : float64

Z-component of vector.

returns → Vec3D

The resulting vector.

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

Orthogonalize


public static method Orthogonalize → (3)

normal ref : Vec3D

Normal vector (will be normalized only).

tangent ref : Vec3D

Tangent vector.

bitangent ref : Vec3D

Bitangent vector.

Orthogonalizes the given vectors using the Gram-Schmidt algorithm.

To​Array


public method ToArray → (4)

values in : float64 [ ]

[not-null]
The output array.

offset opt : int32 = 0

Offset into values in to top-left matrix element.

strideRow opt : int32 = 3

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

Vec3D.ToString2

Public / Attributes

Determinant


public attribute Determinant → (get)

value : float64

The determinant value.

Returns the determinant of this matrix.

Inverse


public attribute Inverse → (get)

value : Mat3D

The inverse matrix.

Returns the inverse of this matrix.

M11


public readonly attribute M11 → (float64)

Matrix component in first row, first column.

M12


public readonly attribute M12 → (float64)

Matrix component in first row, second column.

M13


public readonly attribute M13 → (float64)

Matrix component in first row, third column.

M21


public readonly attribute M21 → (float64)

Matrix component in second row, first column.

M22


public readonly attribute M22 → (float64)

Matrix component in second row, second column.

M23


public readonly attribute M23 → (float64)

Matrix component in second row, third column.

M31


public readonly attribute M31 → (float64)

Matrix component in third row, first column.

M32


public readonly attribute M32 → (float64)

Matrix component in third row, second column.

M33


public readonly attribute M33 → (float64)

Matrix component in third row, third column.

Transpose


public attribute Transpose → (get)

value : Mat3D

The transposed matrix.

Returns the transpose of this matrix.

Serialization

Serializer


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

The serialization helper object for values of Mat3D.