TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

struct Mat3D in Tinman.Core.Math.Vectors

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

struct Mat3D implements IEquatable<Mat3D>

Remarks

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

Public / Attributes

Determinant

Returns the determinant of this matrix.

public property Determinant { get }
type float64
value The determinant value.

Inverse

Returns the inverse of this matrix.

public property Inverse { get }
type Mat3D
value The inverse matrix.

M11

Matrix component in first row, first column.

public readonly field M11
type float64

M12

Matrix component in first row, second column.

public readonly field M12
type float64

M13

Matrix component in first row, third column.

public readonly field M13
type float64

M21

Matrix component in second row, first column.

public readonly field M21
type float64

M22

Matrix component in second row, second column.

public readonly field M22
type float64

M23

Matrix component in second row, third column.

public readonly field M23
type float64

M31

Matrix component in third row, first column.

public readonly field M31
type float64

M32

Matrix component in third row, second column.

public readonly field M32
type float64

M33

Matrix component in third row, third column.

public readonly field M33
type float64

Transpose

Returns the transpose of this matrix.

public property Transpose { get }
type Mat3D
value The transposed matrix.

Public / Constants

Identity

The identity matrix.

public static readonly field Identity
type Mat3D

Zero

The zero matrix.

public static readonly field Zero
type Mat3D

Public / Constructors

FromColumns

Creates a new instance of Mat3D.

[Pure]
public static method FromColumns (Vec3D col1, Vec3D col2, Vec3D col3)
type Mat3D
params col1 The first column vector.
  col2 The second column vector.
  col3 The third column vector.
returns The matrix.

FromRows

Creates a new instance of Mat3D.

[Pure]
public static method FromRows (Vec3D row1, Vec3D row2, Vec3D row3)
type Mat3D
params row1 The first row vector.
  row2 The second row vector.
  row3 The third row vector.
returns The matrix.

Mat3D

Creates a new instance of Mat3D.

public constructor Mat3D (float64 m11, float64 m12, float64 m13, float64 m21, float64 m22, float64 m23, float64 m31, float64 m32, float64 m33)
params m11 Matrix component in first row, first column.
  m12 Matrix component in first row, second column.
  m13 Matrix component in first row, third column.
  m21 Matrix component in second row, first column.
  m22 Matrix component in second row, second column.
  m23 Matrix component in second row, third column.
  m31 Matrix component in third row, first column.
  m32 Matrix component in third row, second column.
  m33 Matrix component in third row, third column.

Orthogonalize

Orthogonalizes the given vectors using the Gram-Schmidt algorithm.

public static method Orthogonalize (ref Vec3D normal, ref Vec3D tangent, ref Vec3D bitangent)
params normal Normal vector (will be normalized only).
  tangent Tangent vector.
  bitangent Bitangent vector.

Rotate

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

[Pure]
public static method Rotate (Vec3D axis, float64 angle)
type Mat3D
params axis Unit-length rotation axis vector.
  angle The rotation angle, in radians.
returns The resulting matrix.

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

[Pure]
public static method Rotate (float64 x, float64 y, float64 z, float64 angle)
type Mat3D
params x X-component of unit-length rotation axis vector.
  y Y-component of unit-length rotation axis vector.
  z Z-component of unit-length rotation axis vector.
  angle The rotation angle, in radians.
returns The resulting matrix.

RotateX

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

[Pure]
public static method RotateX (float64 angle)
type Mat3D
params angle The rotation angle, in radians.
returns The resulting matrix.

RotateY

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

[Pure]
public static method RotateY (float64 angle)
type Mat3D
params angle The rotation angle, in radians.
returns The resulting matrix.

RotateZ

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

[Pure]
public static method RotateZ (float64 angle)
type Mat3D
params angle The rotation angle, in radians.
returns The resulting matrix.

Scale

Returns a scaling matrix.

[Pure]
public static method Scale (float64 f)
type Mat3D
params f The scale factor.
returns The resulting matrix.

Returns a scaling matrix.

[Pure]
public static method Scale (Vec3D f)
type Mat3D
params f The scale factors.
returns The resulting matrix.

Returns a scaling matrix.

[Pure]
public static method Scale (float64 fx, float64 fy, float64 fz)
type Mat3D
params fx The scale factor along the X-axis.
  fy The scale factor along the Y-axis.
  fz The scale factor along the Z-axis.
returns The resulting matrix.

TangentSpace

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

[Pure]
public static method TangentSpace (Vec3D x, Vec3D y, Vec3D z, int32 orthogonalize = 0)
type Mat3D
params x The vector in object space to map to the tangent space X-axis.
  y The vector in object space to map to the tangent space Y-axis.
  z The vector in object space to map to the tangent space Z-axis.
  orthogonalize Depicts how to orthogonalize the tangent space vectors:
  • 0: Skip orthogonalization, only normalize to unit-length.
  • 1: x, y, z
  • 2: x, z, y
  • 3: y, x, z
  • 4: y, z, x
  • 5: z, x, y
  • 6: z, y, x
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). Defaults to 0.
returns 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.

Translate

Returns a homogeneous 2D translation matrix.

[Pure]
public static method Translate (Vec2D v)
type Mat3D
params v The 2D translation vector.
returns The resulting matrix.

Returns a homogeneous 2D translation matrix.

[Pure]
public static method Translate (float64 x, float64 y)
type Mat3D
params x X-component of translation vector.
  y Y-component of translation vector.
returns The resulting matrix.

Warp

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

[Pure]
public static method Warp (Vec2D a, Vec2D b, Vec2D c, Vec2D d)
type Mat3D
params a First vertex of convex quadrilateral.
  b Second vertex of convex quadrilateral.
  c Third vertex of convex quadrilateral.
  d Fourth vertex of convex quadrilateral.
returns The homogeneous 2D warp matrix.

Remarks:

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

Compares this object with the given one.

[Pure]
public method Equals (Mat3D other)
type bool
params other The object to compare to.
returns true if this object is equal to other, false if not.

EqualsAlmost

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

[Pure]
public method EqualsAlmost (Mat3D other)
type bool
params other The other matrix.
returns true if both matrices are similar, false if they are not.

See also:

Maths.Similar

GetColumn

Returns a column vector.

[Pure]
public method GetColumn (int32 index)
type Vec3D
params index The zero-based column index.
returns The column vector.

GetRow

Returns a row vector.

[Pure]
public method GetRow (int32 index)
type Vec3D
params index The zero-based row index.
returns The row vector.

Mul

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

[Pure]
public method Mul (Mat3D m)
type Mat3D
params m The matrix.
returns The resulting matrix.

Mul2

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

[Pure]
public method Mul2 (Vec2D v, float64 w)
type Vec2D
params v The vector.
  w The W-component to assume.
returns 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 Mul2 (float64 x, float64 y, float64 w)
type Vec2D
params x X-component of vector.
  y Y-component of vector.
  w The W-component to assume.
returns The resulting vector, scaled by 1/result.W.

Mul3

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

[Pure]
public method Mul3 (Vec3D v)
type Vec3D
params v The vector.
returns The resulting vector.

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

[Pure]
public method Mul3 (float64 x, float64 y, float64 z)
type Vec3D
params x X-component of vector.
  y Y-component of vector.
  z Z-component of vector.
returns The resulting vector.

ToArray

Copies matrix elements to the given array.

public method ToArray ([] float64[] values, int32 offset = 0, int32 strideRow = 3, int32 strideCol = 1)
params values [not-null] The output array.
  offset Offset into values to top-left matrix element. Defaults to 0.
  strideRow Array index distance between matrix rows. Defaults to 4.
  strideCol Array index distance between matrix columns. Defaults to 1.

Remarks:

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

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

Serialization

Serializer

The serialization helper object for values of Mat3D.

public static readonly field Serializer
type ITypeSerializer<Mat3D>