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

struct Mat3F in Tinman.Core.Math.Vectors

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

struct Mat3F implements IEquatable<Mat3F>

Remarks

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

Serialization

Serializer

The serialization helper object for values of Mat3F.

public static readonly field Serializer
type ITypeSerializer<Mat3F>

Public / Constants

Identity

The identity matrix.

public static readonly field Identity
type Mat3F

Zero

The zero matrix.

public static readonly field Zero
type Mat3F

Public / Attributes

Determinant

Returns the determinant of this matrix.

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

Inverse

Returns the inverse of this matrix.

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

M11

Matrix component in first row, first column.

public readonly field M11
type float32

M12

Matrix component in first row, second column.

public readonly field M12
type float32

M13

Matrix component in first row, third column.

public readonly field M13
type float32

M21

Matrix component in second row, first column.

public readonly field M21
type float32

M22

Matrix component in second row, second column.

public readonly field M22
type float32

M23

Matrix component in second row, third column.

public readonly field M23
type float32

M31

Matrix component in third row, first column.

public readonly field M31
type float32

M32

Matrix component in third row, second column.

public readonly field M32
type float32

M33

Matrix component in third row, third column.

public readonly field M33
type float32

Transpose

Returns the transpose of this matrix.

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

Public / Constructors

Mat3F

Creates a new instance of Mat3F.

public constructor Mat3F (float32 m11, float32 m12, float32 m13, float32 m21, float32 m22, float32 m23, float32 m31, float32 m32, float32 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.

Public / Methods

Equals

public method Equals (Mat3F other)
type bool
params other

EqualsAlmost

public method EqualsAlmost (Mat3F other)
type bool
params other

Mul

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

[Pure]
public method Mul (Mat3F m)
type Mat3F
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 (Vec2F v, float32 w)
type Vec2F
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 (float32 x, float32 y, float32 w)
type Vec2F
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 (Vec3F v)
type Vec3F
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 (float32 x, float32 y, float32 z)
type Vec3F
params x X-component of vector.
  y Y-component of vector.
  z Z-component of vector.
returns The resulting vector.

Orthogonalize

Orthogonalizes the given vectors using the Gram-Schmidt algorithm.

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

Rotate

public static method Rotate (Vec3F axis, float32 angle)
type Mat3F
params axis
  angle

public static method Rotate (float32 x, float32 y, float32 z, float32 angle)
type Mat3F
params x
  y
  z
  angle

RotateX

Returns a rotation matrix (counter-clockwise around X-axis).

public static method RotateX (float32 angle)
type Mat3F
params angle The rotation angle, in radians.
returns The resulting matrix.

RotateY

Returns a rotation matrix (counter-clockwise around Y-axis).

public static method RotateY (float32 angle)
type Mat3F
params angle The rotation angle, in radians.
returns The resulting matrix.

RotateZ

Returns a rotation matrix (counter-clockwise around Z-axis).

public static method RotateZ (float32 angle)
type Mat3F
params angle The rotation angle, in radians.
returns The resulting matrix.

Scale

Returns a scaling matrix.

public static method Scale (float32 f)
type Mat3F
params f The scale factor.
returns The resulting matrix.

Returns a scaling matrix.

public static method Scale (Vec3F f)
type Mat3F
params f The scale factors.
returns The resulting matrix.

Returns a scaling matrix.

public static method Scale (float32 fx, float32 fy, float32 fz)
type Mat3F
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 (Vec3F x, Vec3F y, Vec3F z, int32 orthogonalize = 0)
type Mat3F
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' and the normalized and orthogonalized tangent space basis vectors.

ToArray

Copies matrix elements to the given array.

[Pure]
public method ToArray ([] float32[] 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).

Translate

public static method Translate (Vec2F v)
type Mat3F
params v

public static method Translate (float32 x, float32 y)
type Mat3F
params x
  y

Warp

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

public static method Warp (Vec2F a, Vec2F b, Vec2F c, Vec2F d)
type Mat3F
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.