Linear algebra implementation¶
Conventions:
Column-major
Right hand rule
Vectors¶
vector_t<T,D>
is a templated D-dimensional vector type.
D-dimension operations:
unary minus operator
scalar-vector addition, subtraction, multiplication and division
vector component-wise addition, subtraction
D-dimension functions:
component-wise multiplication is given by
hadamard_product
dot product is given by
dot
length
andnormalize
min
andmax
between two vectorsmin
andmax
for vector components
D-dimension boolean functions:
lessThan
,greatherThan
lessThanEqual
,greatherThanEqual
equal
,notEqual
any
,all
&complement
Specializations for 2D, 3D and 4D vectors are provided with the following features:
Zero initialization default constructor
Parametric constructors
3D
cross
product
## Matrices
matrix_t<T,D>
is a templated D-dimensional square matrix type. Matrices are stored in column memory layout.
User can either access a single value or a column vector using the following attributes:
union
{
T at[D*D];
vector_t<T,D> col[D];
};
Defined operators:
scalar-matrix addition, subtraction, multiplication and division
matrix-matrix addition, subtraction, multiplication
boolean equality and inequality
bracket operators
[i]
to access the ith column vectorsparenthesis operators
(r,c)
to access a single value
D-dimension functions:
trace
transpose
matrix/matrix multiplication
Specializations for 2D, 3D and 4D vectors are provided with the following features:
fromRows(...)
static function to construct matrices from row vectors (2x2,3x3,4x4)fromAffine(mat3,vec3)
for 4D matricesdeterminant
,inverse
Affine transformation¶
This namespace construct 3x3 matrices depicting affine transformations:
scale(sx,sy,sz)
for axis-aligned non uniform scalingscale(v,s)
for scaling in a given direction (must be normalized)rotate_x(angle), rotate_y(angle), rotate_z(angle)
to rotate around a world axisrotate_euler(alpha, beta, gamma)
to rotate using euler anglesrotate_intrinsic(yaw, pitch, roll)
to rotate using Bryyn-Tait anglesrotate(axis, angle)
to rotate around a given normalized axis (must be normalized)reflect(axis)
to reflect along a plane given by its normal vector (must be normalized)involution(axis)
to reflect along a vector (must be normalized)
Camera¶
This namespace construct 4x4 matrices used for camera transformations:
lookat(origin, target, up)
perspective(fox_y, aspect, near, far)
orthographic(left, right, top, bot, near, far)
Quaternion¶
TODO: