Matrix

Base template for all matrix types. See predefined matrix types

nothrow @nogc
struct Matrix (
type
int numCols
int numRows
) if (
(numCols > 1) &&
(numRows > 1)
) {}

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(type 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

this
this(Q_OR_DQ q)

Construct a matrix from a quaternion or dual quaternion

Alias This

data

Members

Aliases

cols
alias cols = numCols
Undocumented in source.
rows
alias rows = numRows
Undocumented in source.
valueType
alias valueType = type
Undocumented in source.
vectorType
alias vectorType = Vector!(type, rows)
Undocumented in source.

Functions

clear
void clear(type value)

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

isIdentity
bool isIdentity()

Returns a identity matrix.

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(Matrix mat)

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

opBinary
Matrix opBinary(M mat)

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

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

opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(T val)
Undocumented in source. Be warned that the author may not have intended to support it.
ptr
auto ptr()

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

rotate
Matrix rotate(real angle)

rotate an existing matrix

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

rotate an existing matrix with an angle around an axis

rotate
Matrix rotate(real angle, type x, type y, type 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(type x)

scale an existing matrix

scale
Matrix scale(type[2] vec)

scale an existing matrix with an array/vector

scale
Matrix scale(type x, type y)

scale an existing matrix with two scalars

scale
Matrix scale(type[3] vec)

scale an existing matrix with an array/vector

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

scale an existing matrix with three scalars

scale
Matrix scale()

extract scaling part of the matrix in a copy

toString
char[] toString(char[] buffer)

Returns the current matrix formatted as flat string.

translate
Matrix translate(type x)

translate an existing matrix

translate
Matrix translate(type[2] vec)

translate an existing matrix with an array/vector

translate
Matrix translate(type x, type y)

translate an existing matrix with two scalars

translate
Matrix translate(type[3] vec)

translate an existing matrix with a vector

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

translate an existing matrix with three scalars

translation
Matrix translation()

extract translation part of the matrix in a copy

Static functions

identity
Matrix identity()

static create identity matrix

isCompatibleMatrixImpl
void isCompatibleMatrixImpl(Matrix!(type, col, row) mat)
Undocumented in source. Be warned that the author may not have intended to support it.
isCompatibleVectorImpl
void isCompatibleVectorImpl(Vector!(type, dim) vec)
Undocumented in source. Be warned that the author may not have intended to support it.
rotation
Matrix rotation(real angle)

static construction of a rotation matrix

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

static construction of a rotation matrix angle and axis

rotation
Matrix rotation(real angle, type x, type y, type 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(type x)

static construction of a scaling matrix

scaling
Matrix scaling(type[2] vec)

static construction of a scaling matrix from an array/vector

scaling
Matrix scaling(type x, type y)

static construction of a scaling matrix from two scalars

scaling
Matrix scaling(type[3] vec)

static construction of a scaling matrix from an array/vector

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

static construction of a scaling matrix from three scalars

translation
Matrix translation(type x)

static construction of a translation matrix

translation
Matrix translation(type[2] vec)

static construction of a translation matrix from an array/vector

translation
Matrix translation(type x, type y)

static construction of a translation matrix from two coordinates

translation
Matrix translation(type[3] vec)

static construction of a translation matrix from an array/vector

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

static construction of a translation matrix from three coordinates

Templates

isCompatibleMatrix
template isCompatibleMatrix(T)

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

isCompatibleVector
template isCompatibleVector(T)
Undocumented in source.

Variables

data
vectorType[cols] data;

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

Parameters

type

the value type of each matrix element

Meta