matrix3.c file
Functions
- auto mat3_identity(void) -> matrix3
- Constructs the 3x3 identity matrix.
- auto mat3_mul(matrix3 a, matrix3 b) -> matrix3
- Multiplies two 3x3 matrices.
- auto mat3_transpose(matrix3 m) -> matrix3
- Computes the transpose of a 3x3 matrix.
- auto mat3_inverse(matrix3 m) -> matrix3
- Computes the inverse of a 3x3 matrix.
-
auto mat3_rotation_z(vm_
float_ t radians) -> matrix3 - Constructs a 3x3 rotation matrix around the Z axis.
-
auto mat3_rotation_z_deg(vm_
float_ t degrees) -> matrix3 - Constructs a 3x3 rotation matrix around the Z axis.
-
auto mat3_determinant(matrix3 m) -> vm_
float_ t - Computes the determinant of a 3x3 matrix.
- auto mat3_mul_vec3(matrix3 m, vector3 v) -> vector3
- Multiplies a 3x3 matrix by a vector3.
- auto mat3_mul_vec2(matrix3 m, vector2 v) -> vector2
- Applies a 3x3 affine transform to a vector2.
-
auto mat3_rotation_x(vm_
float_ t radians) -> matrix3 - Constructs a 3x3 rotation matrix around the X axis.
-
auto mat3_rotation_x_deg(vm_
float_ t degrees) -> matrix3 - Constructs a 3x3 rotation matrix around the X axis.
-
auto mat3_rotation_y(vm_
float_ t radians) -> matrix3 - Constructs a 3x3 rotation matrix around the Y axis.
-
auto mat3_rotation_y_deg(vm_
float_ t degrees) -> matrix3 - 3x3 rotation about Y from an angle in degrees.
- auto mat3_translate(vector2 t) -> matrix3
- Builds a 3x3 2D translation matrix.
- auto mat3_scale(vector2 s) -> matrix3
- Builds a 3x3 2D scaling matrix.
- auto mat3_from_mat4(matrix4 m) -> matrix3
- Copies the upper-left 3x3 of a matrix4.
- auto mat3_normal(matrix3 m) -> matrix3
- Inverse-transpose of a 3x3 (normal matrix).
- auto mat3_sym_eigen(matrix3 m, matrix3* axes) -> vector3
- Analytical eigenvalues of a symmetric 3×3, sorted ascending.
Function documentation
matrix3 mat3_transpose(matrix3 m)
Computes the transpose of a 3x3 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The transposed matrix. |
matrix3 mat3_inverse(matrix3 m)
Computes the inverse of a 3x3 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The inverse matrix. |
On a singular matrix the result is identity.
matrix3 mat3_rotation_z(vm_ float_ t radians)
Constructs a 3x3 rotation matrix around the Z axis.
| Parameters | |
|---|---|
| radians | Rotation angle in radians. |
| Returns | The rotation matrix3. |
matrix3 mat3_rotation_z_deg(vm_ float_ t degrees)
Constructs a 3x3 rotation matrix around the Z axis.
| Parameters | |
|---|---|
| degrees | The rotation angle in degrees. |
| Returns | The resulting rotation matrix3. |
The angle is given in degrees and internally converted to radians.
vm_ float_ t mat3_determinant(matrix3 m)
Computes the determinant of a 3x3 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The determinant value. |
matrix3 mat3_rotation_x(vm_ float_ t radians)
Constructs a 3x3 rotation matrix around the X axis.
| Parameters | |
|---|---|
| radians | Rotation angle in radians. |
| Returns | The rotation matrix3. |
matrix3 mat3_rotation_x_deg(vm_ float_ t degrees)
Constructs a 3x3 rotation matrix around the X axis.
| Parameters | |
|---|---|
| degrees | The rotation angle in degrees. |
| Returns | The rotation matrix3. |
The angle is provided in degrees and converted to radians internally.
matrix3 mat3_rotation_y(vm_ float_ t radians)
Constructs a 3x3 rotation matrix around the Y axis.
| Parameters | |
|---|---|
| radians | The rotation angle in radians. |
| Returns | The rotation matrix3. |
matrix3 mat3_rotation_y_deg(vm_ float_ t degrees)
3x3 rotation about Y from an angle in degrees.
| Parameters | |
|---|---|
| degrees | Rotation angle in degrees. |
| Returns | Rotation matrix3. |
matrix3 mat3_translate(vector2 t)
Builds a 3x3 2D translation matrix.
| Parameters | |
|---|---|
| t | Translation vector. |
| Returns | The resulting matrix3. |
matrix3 mat3_scale(vector2 s)
Builds a 3x3 2D scaling matrix.
| Parameters | |
|---|---|
| s | Scale vector. |
| Returns | The resulting matrix3. |
matrix3 mat3_from_mat4(matrix4 m)
Copies the upper-left 3x3 of a matrix4.
| Parameters | |
|---|---|
| m | Input matrix. |
| Returns | The resulting matrix3. |
matrix3 mat3_normal(matrix3 m)
Inverse-transpose of a 3x3 (normal matrix).
| Parameters | |
|---|---|
| m | Linear part of a model transform. |
| Returns | The normal matrix3. |
vector3 mat3_sym_eigen(matrix3 m, matrix3* axes)
Analytical eigenvalues of a symmetric 3×3, sorted ascending.
| Parameters | |
|---|---|
| m | Input matrix (symmetrized internally). |
| axes | Optional; receives eigenvector columns. May be NULL. |
| Returns | Eigenvalues as a vector3, sorted ascending. |
m is symmetrized as (A+Aᵀ)/2. Eigenvalues are sorted ascending. Eigenvectors are the columns of axes when non-NULL (axes * diag(moments) * axesᵀ ~= m). Analytical closed form; not routed through heap SVD or Jacobi.