mat3
3x3 matrix of floats (rotations, linear maps).
Fields and methods
Members of the struct matrix_stack<float,3,3>. Most of what you do with a CGP type goes through the free functions listed below.
Fields
numarray_stack<numarray_stack<float,3>,3> data | Coefficients stored row by row as 3 rows of 3 floats, contiguous in memory. |
Methods
matrix_stack() | Builds a matrix with all elements set to zero.10 overloads src |
matrix_stack(numarray_stack<vec3,3> const& elements) | Builds a mat3 from an array of three vec3 rows. src |
matrix_stack(vec3 const& row_1, vec3 const& row_2, vec3 const& row_3) | Builds a mat3 from its three rows (not columns). src |
matrix_stack(numarray_stack<float,9> const& elements) | Builds a mat3 from 9 values in row-major order. src |
matrix_stack(float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz) | Builds a mat3 from its 9 elements given row by row (xx, xy, xz, yx, ..., zz). src |
matrix_stack(matrix_stack<float,N1_arg,N2_arg> const& M) | Builds a mat2, mat3 or mat4 from a float matrix of another size (explicit), copying the common top-left block and setting the other elements to zero (a mat4 built from a mat3 uses the dedicated constructor instead, which puts 1 at (3,3)). src |
matrix_stack(float value) | Builds the mat2, mat3 or mat4 with the given value on the whole diagonal and zeros elsewhere (explicit, as in glm). src |
matrix_stack(float xx, float yy, float zz) | Builds the diagonal mat3 diag(xx, yy, zz) (explicit). src |
matrix_stack(std::initializer_list<float> const& arg) | Builds a mat2, mat3 or mat4 from a brace list of floats; N*N or more values fill it in row-major order (extra ones ignored), 1 value or N values build a diagonal matrix (mat4 also accepts 3 values, with 1 as last diagonal element), and any other count raises an error. src |
matrix_stack(std::initializer_list<vec3> const& arg) | Builds a mat3 from a brace list of at least three vec3 rows (asserted); extra rows are ignored. src |
| Returns the total number of elements N1*N2 (4, 9 and 16 for mat2, mat3 and mat4). src | |
| Returns the dimensions {N1, N2} (number of rows, number of columns) as an int2. src | |
| Sets every element to the given value and returns a reference to the matrix. src | |
| Returns the identity matrix (ones on the main diagonal, zeros elsewhere; for a non-square generic matrix the diagonal has min(N1,N2) ones). src | |
| Returns a mat2, mat3 or mat4 with all elements equal to zero. src | |
| Returns a mat2, mat3 or mat4 with all elements equal to the given value. src | |
static mat3 build_diagonal(float value) | Returns the mat2, mat3 or mat4 with the given value on the whole diagonal (including element (3,3) of a mat4) and zeros elsewhere.3 overloads src |
static mat3 build_diagonal(vec3 const& arg) | Returns the diagonal mat3 whose diagonal is the given vec3. src |
static mat3 build_diagonal(float x, float y, float z) | Returns the diagonal mat3 diag(x, y, z). src |
static mat3 build_scaling(float value) | Returns the uniform scaling matrix of the given factor; same as build_diagonal for mat2 and mat3, while a mat4 keeps 1 as element (3,3).3 overloads src |
static mat3 build_scaling(vec3 const& arg) | Returns the scaling matrix of factors (arg.x, arg.y, arg.z); for mat3 the diagonal matrix, for mat4 diag(arg.x, arg.y, arg.z, 1). src |
static mat3 build_scaling(float x, float y, float z) | Returns the scaling matrix of factors (x, y, z); for mat3 the diagonal matrix, for mat4 diag(x, y, z, 1). src |
| Returns the matrix (mat3, or mat4 with zero translation) of the rotation of angle in radians around axis, normalized internally. src | |
| Returns the matrix (mat3, or mat4 with zero translation) of the rotation of a unit quaternion, whose norm is asserted to be within 0.05 of 1. src | |
| Returns a const reference to row k (a vec2, vec3 or vec4 for mat2, mat3 or mat4), with bound checking unless CGP_NO_DEBUG is defined. src | |
vec3 const& operator()(int k2) constvec3& operator()(int k2) | Returns a const reference to row k1 (a vector of N2 elements), with bound checking unless CGP_NO_DEBUG is defined.2 overloads src |
float const& operator()(int k1, int k2) constfloat& operator()(int k1, int k2) | Returns a const reference to the element at row k1 and column k2, with bound checking unless CGP_NO_DEBUG is defined. src |
vec3 const& at(int k2) constvec3& at(int k2) | For mat2 and mat3, returns a const reference to row k, bound-checked through the row array unless CGP_NO_DEBUG is defined.2 overloads src |
float const& at(int k1, int k2) constfloat& at(int k1, int k2) | Returns a const reference to the element at row k1 and column k2; bound-checked for mat2, mat3 and mat4 (unless CGP_NO_DEBUG is defined) but not for the generic matrix_stack. src |
float const& coeff(int k1, int k2) constfloat& coeff(int k1, int k2) | Returns a const reference to the element at row k1 and column k2, without bound checking.2 overloads src |
vec3 const& coeff(int k1) constvec3& coeff(int k1) | Returns a const reference to row k1, without bound checking. src |
| Returns a const reference to the element at the row-major offset k1*N2+k2; bound-checked for the generic matrix and mat4 (unless CGP_NO_DEBUG is defined) but not for mat2 and mat3. src | |
| Returns a const reference to the element at the given row-major offset, without bound checking. src | |
| Returns the (N1-1)x(N2-1) matrix obtained by removing row k1 and column k2 (asserts k1<N1 and k2<N2), e.g. a mat2 for a mat3. src | |
| Copies a smaller matrix into this one with its top-left corner at (offset_1, offset_2), default (0,0), and returns a reference to this matrix; the block must fit (static_assert on its size, assert on the offsets). src | |
| Returns a const pointer to the first element (0,0) of the contiguous row-major storage. src | |
| Returns a const pointer one past the last element (N1-1,N2-1) of the contiguous row-major storage. src | |
| Returns a const pointer to the first element (0,0) of the contiguous row-major storage. src | |
| Returns a const pointer one past the last element (N1-1,N2-1) of the contiguous row-major storage. src |
Functions taking a mat3
Transform 1
Compute 1
Convert 1
Other 1
Documented on another page
opengl_uniformSend a mat3 uniform (row-major, transposed on upload) to the shader; warns if the uniform is not found and expected is true.onopengl_shader_structure
Functions returning a mat3
Construct 1
mat3 tensor_product(vec3 const& a, vec3 const& b)Outer product a * transpose(b), as a 3x3 matrix.
Operators
Show the 7 operators (+, -, *, ==, ...)
operator*
3 overloadsmat4 operator*(mat3 const& T1, affine const& T2)sourceProduct of a mat3 extended to a mat4 with the 4x4 matrix of the affine transform.
mat4 operator*(mat3 const& T1, affine_rt const& T2)sourceProduct of a mat3 extended to a mat4 with the 4x4 matrix of the rigid transform.
mat4 operator*(mat3 const& T1, affine_rts const& T2)sourceProduct of a mat3 extended to a mat4 with the 4x4 matrix of the transform.
Documented on another page
operator*Product of the 4x4 matrix of the affine transform with a mat3 extended to a mat4.onaffineoperator*Product of the 4x4 matrix of the rigid transform with a mat3 extended to a mat4.onaffine_rtoperator*Product of the 4x4 matrix of the transform with a mat3 extended to a mat4.onaffine_rtsoperator*Product of the rotation matrix with a mat3.onrotation_transform