Matrix

Base template for all matrix types. See predefined matrix types

struct Matrix (
type
int numCols
int numRows
) if (
(numCols > 1) &&
(numRows > 1)
) {
Matrix result;
}

Constructors

this
this(Args args)

Constructs the matrix: If a single value is passed, the matrix will be cleared with this value ( each column in each col will contain this value ). If a matrix with more cols and columns is passed, the matrix will be the upper left nxm matrix. If a matrix with less cols and columns is passed, the passed matrix will be stored in the upper left of an identity matrix. It's also allowed to pass vectors and scalars at a time, but the vectors dimension must match the number of columns and align correctly.

this
this(T mat)

Construct a Matrix from another Matrix, equal sized or bigger Construct a Matrix from another Matrix

this
this(valueType value)

Construct a Matrix from a single value, for non- and square matrices see GLSL 4.5 Spec, section 5.4.2 Vector and Matrix Constructors

Alias This

data

Members

Functions

clear
void clear(valueType value)

Sets all values of the matrix to value ( each column in each col will contain this value ).

opBinary
auto opBinary(T s)

Component-wise binary matrix-scalar operation: addition, subtraction, multiplication, division

opBinary
auto opBinary(V vec)

matrix-vector multiplication

opBinary
Matrix opBinary(M mat)

matrix-matrix multiplication, using matrix-vector multiplication for each column of mat

opBinary
Matrix opBinary(Matrix mat)

matrix-matrix component-wise operations addition, subtraction and division, using vector-vector operations of all colums

opBinaryRight
auto opBinaryRight(T s)

Component-wise binary scalar-matrix operation: addition, subtraction, multiplication, division

opBinaryRight
auto opBinaryRight(V vec)

vector-Matrix multiplication, optimized instead of transposing matrix and multiplying

rotate
Matrix rotate(real angle)

rotate an existing matrix

rotate
Matrix rotate(real angle, Vector!(valueType, 3) axis)

rotate an existing matrix with an angle around an axis

rotate
Matrix rotate(real angle, valueType x, valueType y, valueType z)

rotate an existing matrix with an angle around axis coordinates

rotateX
Matrix rotateX(real angle)

rotate an existing matrix with an angle around X axis

rotateY
Matrix rotateY(real angle)

rotate an existing matrix with an angle around Y axis

rotateZ
Matrix rotateZ(real angle)

rotate an existing matrix with an angle around Z axis

rotation
Matrix rotation()

extract rotation part of the matrix in a copy

scale
Matrix scale(valueType x)

scale an existing matrix

scale
Matrix scale(valueType[2] vec)

scale an existing matrix with an array/vector

scale
Matrix scale(valueType x, valueType y)

scale an existing matrix with two scalars

scale
Matrix scale(valueType[3] vec)

scale an existing matrix with an array/vector

scale
Matrix scale(valueType x, valueType y, valueType z)

scale an existing matrix with three scalars

scale
Matrix scale()

extract scaling part of the matrix in a copy

translate
Matrix translate(valueType x)

translate an existing matrix

translate
Matrix translate(valueType[2] vec)

translate an existing matrix with an array/vector

translate
Matrix translate(valueType x, valueType y)

translate an existing matrix with two scalars

translate
Matrix translate(valueType[3] vec)

translate an existing matrix with a vector

translate
Matrix translate(valueType x, valueType y, valueType z)

translate an existing matrix with three scalars

translation
Matrix translation()

extract translation part of the matrix in a copy

Properties

asPrettyString
string asPrettyString [@property getter]

Returns the current matrix as pretty formatted string. TODO : Check This

asString
string asString [@property getter]

Returns the current matrix formatted as flat string.

identity
Matrix identity [@property getter]

static create identity matrix

isIdentity
bool isIdentity [@property getter]

Returns a identity matrix.

ptr
auto ptr [@property getter]

Returns the pointer to the stored values as OpenGL requires it. Note this will return a pointer to a $( RED column - major ) matrix, $( RED this is the OpneGL convention and expected in programs via Uniforms or UBOs ).

Static functions

rotation
Matrix rotation(real angle)

static construction of a rotation matrix

rotation
Matrix rotation(real angle, Vector!(valueType, 3) axis)

static construction of a rotation matrix angle and axis

rotation
Matrix rotation(real angle, valueType x, valueType y, valueType z)

static construction of a rotation matrix angle and axis coordinates

rotationX
Matrix rotationX(real angle)

static construction of a rotation matrix with an angle around X axis

rotationY
Matrix rotationY(real angle)

static construction of a rotation matrix with an angle around Y axis

rotationZ
Matrix rotationZ(real angle)

static construction of a rotation matrix with an angle around Z axis

scaling
Matrix scaling(valueType x)

static construction of a scaling matrix

scaling
Matrix scaling(valueType[2] vec)

static construction of a scaling matrix from an array/vector

scaling
Matrix scaling(valueType x, valueType y)

static construction of a scaling matrix from two scalars

scaling
Matrix scaling(valueType[3] vec)

static construction of a scaling matrix from an array/vector

scaling
Matrix scaling(valueType x, valueType y, valueType z)

static construction of a scaling matrix from three scalars

translation
Matrix translation(valueType x)

static construction of a translation matrix

translation
Matrix translation(valueType[2] vec)

static construction of a translation matrix from an array/vector

translation
Matrix translation(valueType x, valueType y)

static construction of a translation matrix from two coordinates

translation
Matrix translation(valueType[3] vec)

static construction of a translation matrix from an array/vector

translation
Matrix translation(valueType x, valueType y, valueType z)

static construction of a translation matrix from three coordinates

Variables

data
vectorType[cols] data;

Holds the matrix $( RED column - major ) in memory./// Each Column is Vector of length rows

Meta