Matrix

Column-major 2D matrix type.

Constructors

this
this(T[numElements] values)

Constructs a Matrix specifying all elements.

this
this(T diag)

Constructs a Matrix specifying the diagonal value.

Members

Aliases

ElementType
alias ElementType = T

Alias for Matrix element type.

ortho
alias ortho = orthographic
Undocumented in source.

Enums

opDollar
eponymoustemplate opDollar(size_t pos : 0)

Row size

opDollar
eponymoustemplate opDollar(size_t pos : 1)

Column size

Functions

columns
auto columns()

Returns a Range of all columns.

columns
auto columns()

Returns a Range of all columns.

copyInto
auto ref copyInto(Matrix!(T, C, R) target)

Copy Matrix values into target Matrix of any dimensions. If dimensions are not the same, the values at non-overlapping indices are ignored.

opBinary
T[columnSize] opBinary(T[rowSize] vec)

Returns the result of multiplying vec by Matrix. If matrix is not square, the resulting array dimension will be different from input.

opBinary
Matrix!(T, OtherColumns, columnSize) opBinary(Matrix!(T, OtherColumns, rowSize) other)

Returns the result of Matrix multiplication.

opCast
U opCast()

Returns a copy of Matrix, adjusting dimensions as necessary. Non-overlapping indices will stay initialized to 0.

opIndex
inout(T)[] opIndex(size_t i)

Index a column.

opIndex
inout(T) opIndex(size_t i, size_t j)

Index an element directly.

opOpAssign
Matrix opOpAssign(Matrix other)

Inplace matrix multiplication with "*=" operator, only available for square matrices.

rows
auto rows()

Returns a Range of all rows.

rows
auto rows()

Returns a Range of all rows.

Manifest constants

columnSize
enum columnSize;

Number of elements in each column, same as the number of rows.

identity
enum identity;

Constant Identity matrix (diagonal values 1).

isSquare
enum isSquare;

Whether matrix is square or not.

minDimension
enum minDimension;

Minimum dimension between number of rows and number of columns.

numElements
enum numElements;

Total number of elements.

rowSize
enum rowSize;

Number of elements in each row, same as the number of columns.

Static functions

fromColumns
Matrix fromColumns(Args args)

Constructs a Matrix from all elements in column-major format.

fromColumns
Matrix fromColumns(T[numElements] elements)

Constructs a Matrix from an array of all elements in column-major format.

fromColumns
Matrix fromColumns(T[rowSize][columnSize] columns)

Constructs a Matrix from a 2D array of columns.

fromDiagonal
Matrix fromDiagonal(T diag)

Constructs a Matrix with all diagonal values equal to diag and all others equal to 0.

fromDiagonal
Matrix fromDiagonal(T[N] diag)

Constructs a Matrix with diagonal values from diag and all others equal to 0.

fromRows
Matrix fromRows(Args args)

Constructs a Matrix from row-major format

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

Returns an orthographic projection matrix.

perspective
Matrix perspective(T fov, T aspectRatio, T near, T far)

Returns a perspective projection matrix.

perspectiveDegrees
auto perspectiveDegrees(T fovDegrees, T aspectRatio, T near, T far)

Calls perspective converting angle from degrees to radians.

Variables

elements
T[numElements] elements;

Matrix underlying elements.

Meta