gfm



struct  Matrix(T, int R, int C);

Generic non-resizeable matrix with R rows and C columns.

Intended for 3D use (size 3x3 and 4x4).

Important:
Matrices here are in row-major order whereas OpenGL is column-major.
Parameters
T type of elements
R number of rows
C number of columns

static pure nothrow @nogc Matrix  fromColumns(column_t[] columns);

Construct a matrix from columns.


static pure nothrow @nogc Matrix  fromRows(row_t[] rows);

Construct a matrix from rows.


pure nothrow @nogc this(U)(T x);

Construct matrix with a scalar.


pure nothrow @nogc ref Matrix  opAssign(U : Matrix)(U x);

Assign with a samey matrice.


pure nothrow @nogc ref Matrix  opAssign(U)(U x) if (isMatrixInstantiation!U && is(U._T : _T) && !is(U : Matrix) && U._R == R && U._C == C);

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


pure nothrow @nogc ref Matrix  opAssign(U)(U x) if (isStaticArray!U && is(typeof(x[0]) : T) && U.length == R * C);

Assign with a static array of size R * C.


pure nothrow @nogc ref Matrix  opAssign(U)(U x) if (isDynamicArray!U && is(typeof(x[0]) : T));

Assign with a dynamic array of size R * C.


inout pure nothrow @nogc @property inout(T)*  ptr();

Return a pointer to content.


const pure nothrow @nogc column_t  column(int j);

Returns
 column j as a vector.

const pure nothrow @nogc row_t  row(int i);

Returns
 row i as a vector.

const nothrow string  toString();

Covnerts to pretty string.


const pure nothrow @nogc column_t  opBinary(string op)(row_t x) if (op == "*");

Matrix * vector multiplication.


const pure nothrow @nogc auto  opBinary(string op, U)(U x) if (isMatrixInstantiation!U && U._R == C && op == "*");

Matrix * matrix multiplication.


const pure nothrow @nogc Matrix  opBinary(string op, U)(U other) if (is(U : Matrix) && (op == "+" || op == "-"));

Matrix add and substraction.


pure nothrow @nogc ref Matrix  opOpAssign(string op, U)(U operand) if (is(U : Matrix));

Assignment operator with another samey matrix.


pure nothrow @nogc ref Matrix  opOpAssign(string op, U)(U operand) if (isConvertible!U);

Assignment operator with another samey matrix.


const pure nothrow @nogc U  opCast(U)() if (isMatrixInstantiation!U);

Cast to other matrix types.

If the size are different, the resulting matrix is truncated

and/or filled with identity coefficients.


const pure nothrow @nogc U  opCast(U)() if (isQuaternionInstantiation!U && is(U._T : _T) && _R == 3 && _C == 3);

Convert 3x3 rotation matrix to quaternion.

See Also
3D Math Primer for Graphics and Game Development.

const pure nothrow @nogc U  opCast(U)() if (isQuaternionInstantiation!U && is(U._T : _T) && _R == 4 && _C == 4);

Converts a 4x4 rotation matrix to quaternion.


const pure nothrow @nogc Matrix  inverse();

Returns
 inverse of matrix.

Matrix inversion is provided for 2x2, 3x3 and 4x4 floating point matrices.

const pure nothrow @nogc Matrix  inverse();

Returns
 inverse of matrix.

const pure nothrow @nogc Matrix  inverse();

Returns
 inverse of matrix.

const pure nothrow @nogc Matrix!(T, C, R)  transposed();

Returns
 transposed matrice.

pure nothrow @nogc void  translate(Vector!(T, R - 1) v);

In-place  translate by (v, 1)


static pure nothrow @nogc Matrix  translation(Vector!(T, R - 1) v);

Make a  translation matrix.


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

In-place matrix scaling.


static pure nothrow @nogc Matrix  scaling(Vector!(T, R - 1) v);

Make a  scaling matrix.


alias  rotateX = rotateAxis!(1, 2);

Returns
rotation matrix along axis X

alias  rotateY = rotateAxis!(2, 0);

Returns
rotation matrix along axis Y

alias  rotateZ = rotateAxis!(0, 1);

Returns
rotation matrix along axis Z

static pure nothrow @nogc Matrix  rotation(T angle, vec3!T axis);

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

See Also
http://www.cs.rutgers.edu/~decarlo/428/gl_man/rotate.html

static pure nothrow @nogc Matrix  orthographic(T left, T right, T bottom, T top, T near, T far);

Returns
 orthographic projection.

static pure nothrow @nogc Matrix  perspective(T FOVInRadians, T aspect, T zNear, T zFar);

Returns
 perspective projection.

static pure nothrow @nogc Matrix  lookAt(vec3!T eye, vec3!T target, vec3!T up);

Returns
" lookAt" projection.

Thanks to vuaru for corrections.

const pure nothrow @nogc Frustum!T  frustum();

Extract  frustum from a 4x4 matrice.


static pure nothrow @nogc Matrix  identity();

Returns
an  identity matrice.
Note:
the  identity matrix, while only meaningful for square matrices,

is also defined for non-square ones.

pure nothrow @nogc Matrix  constant(U)(U x);

Returns
a  constant matrice.