Documentation / @interstellar-tools/equations / applyMatrix3
Function: applyMatrix3()
ts
function applyMatrix3(
M: Matrix3x3Type,
v: Vector3DTupleType
): Vector3DTupleType;Defined in: helpers/apply-matrix-3.ts:38
Apply a 3×3 matrix to a 3D vector (matrix–vector multiplication).
Computes:
With row-major indexing:
M[row][col]v = [x, y, z]
This is commonly used for:
- Applying a direction cosine matrix (DCM) / rotation matrix to transform vectors between frames (e.g., inertial → body-fixed).
- Small 3D linear transforms in geometry and mapping pipelines.
Parameters
| Parameter | Type | Description |
|---|---|---|
M | Matrix3x3Type | 3×3 matrix (row-major) (all finite). |
v | Vector3DTupleType | 3D vector [x, y, z] (all finite). |
Returns
The transformed vector M * v as a 3D tuple.
Example
ts
const M: Matrix3x3Type = [
[1, 0, 0],
[0, 0, -1],
[0, 1, 0]
];
const v: Vector3DTupleType = [1, 2, 3];
const out = applyMatrix3(M, v);
// out === [1, -3, 2]