Matrix

Generic non-resizeable matrix with R rows and C columns. Intended for 3D use (size 3x3 and 4x4). Important: <b>Matrices here are in row-major order whereas OpenGL is column-major.</b>

struct Matrix (
T
int R
int C
) {}

Constructors

this
this(U values)
Undocumented in source.
this
this(T x)

Construct matrix with a scalar.

Members

Aliases

_T
alias _T = T
Undocumented in source.
column_t
alias column_t = Vector!(T, R)
Undocumented in source.
rotateX
alias rotateX = rotateAxis!(1, 2)

Rotate along X axis

rotateY
alias rotateY = rotateAxis!(2, 0)

Rotate along Y axis

rotateZ
alias rotateZ = rotateAxis!(0, 1)

Rotate along Z axis

row_t
alias row_t = Vector!(T, C)
Undocumented in source.

Functions

column
column_t column(int j)

Returns a column as a vector

frustum
Frustum!T frustum()

Extract frustum from a 4x4 matrice.

inverse
Matrix inverse()

Returns an inverted copy of this matrix

inverse
Matrix inverse()

Returns an inverted copy of this matrix

inverse
Matrix inverse()

Returns an inverted copy of this matrix

inverse
Matrix inverse()

Returns an inverted copy of this matrix

opAssign
Matrix opAssign(U x)

Assign with a scalar.

opAssign
Matrix opAssign(U x)

Assign with a samey matrice.

opAssign
Matrix opAssign(U x)

Assign from other small matrices (same size, compatible type).

opAssign
Matrix opAssign(U x)

Assign with a static array of size R * C.

opAssign
Matrix opAssign(U x)

Assign with a static array of shape (R, C).

opAssign
Matrix opAssign(U x)

Assign with a dynamic array of size R * C.

opAssign
Matrix opAssign(U x)

Assign with a dynamic array of shape (R, C).

opBinary
Matrix opBinary(T factor)

Matrix * scalar multiplication.

opBinary
column_t opBinary(row_t x)

Matrix * vector multiplication.

opBinary
auto opBinary(U x)

Matrix * matrix multiplication.

opBinary
Matrix opBinary(U other)

Matrix add and substraction.

opCast
U opCast()

Cast to other matrix types. If the size are different, the resulting matrix is truncated and/or filled with identity coefficients.

opCast
U opCast()

Convert 3x3 rotation matrix to quaternion.

opCast
U opCast()

Converts a 4x4 rotation matrix to quaternion.

opEquals
bool opEquals(U other)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(U other)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
Matrix opOpAssign(U x)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
Matrix opOpAssign(U operand)

Assignment operator with another samey matrix.

opOpAssign
Matrix opOpAssign(U operand)

Matrix += <something convertible to a Matrix> Matrix -= <something convertible to a Matrix>

opUnary
Matrix opUnary()
Undocumented in source. Be warned that the author may not have intended to support it.
ptr
inout(T)* ptr()

Return a pointer to content.

row
row_t row(int i)

Returns a row as a vector

scale
void scale(Vector!(T, R - 1) v)

In-place matrix scaling.

toString
string toString()

Covnerts to pretty string.

translate
void translate(Vector!(T, R - 1) v)

In-place translate by (v, 1)

transposed
Matrix!(T, C, R) transposed()

Returns a transposed copy of this matrix

Manifest constants

_C
enum _C;
Undocumented in source.
_R
enum _R;
Undocumented in source.

Static functions

constant
Matrix constant(U x)

Construct an constant matrix

diag
Matrix diag(Vector!(T, R) v)

Makes a diagonal matrix from a vector.

fromColumns
Matrix fromColumns(column_t[] columns)

Construct a matrix from columns.

fromRows
Matrix fromRows(row_t[] rows)

Construct a matrix from rows.

identity
Matrix identity()

Construct an identity matrix

lookAt
Matrix lookAt(vec3!T eye, vec3!T target, vec3!T up)

Look At projection

orthographic
Matrix orthographic(T left, T right, T bottom, T top, T near, T far)

Orthographic projection

perspective
Matrix perspective(T FOVInRadians, T aspect, T zNear, T zFar)

Perspective projection

rotateAxis
Matrix rotateAxis(T angle)
Undocumented in source. Be warned that the author may not have intended to support it.
rotation
Matrix rotation(T angle, vec3!T axis)

Similar to the glRotate matrix, however the angle is expressed in radians

scaling
Matrix scaling(Vector!(T, R - 1) v)

Make a scaling matrix.

translation
Matrix translation(Vector!(T, R - 1) v)

Make a translation matrix.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

isSquare
enum bool isSquare;
Undocumented in source.

Parameters

T

type of elements

R

number of rows

C

number of columns

Meta