simvx.core.helpers.matrix¶
NumPy matrix helpers for TRS composition and GPU upload.
Module Contents¶
Functions¶
Build model matrix from position, rotation quaternion, and scale. |
|
Build N model matrices from arrays of positions, quaternions, and scales. |
|
Convert mat4 to bytes for GPU upload (64 bytes, row-major float32). |
API¶
- simvx.core.helpers.matrix.mat4_from_trs(pos: tuple[float, float, float] | numpy.ndarray, rot, scl: tuple[float, float, float] | numpy.ndarray) numpy.ndarray[source]¶
Build model matrix from position, rotation quaternion, and scale.
Args: pos: Position (x, y, z) rot: Rotation quaternion — Quat or any object with .w/.x/.y/.z scl: Scale (x, y, z)
Returns: 4x4 model matrix as numpy array (Translate * Rotate * Scale)
- simvx.core.helpers.matrix.batch_mat4_from_trs(positions: numpy.ndarray, rotations: numpy.ndarray, scales: numpy.ndarray) numpy.ndarray[source]¶
Build N model matrices from arrays of positions, quaternions, and scales.
Args: positions: (N, 3) float32 positions rotations: (N, 4) float32 quaternions [w, x, y, z] scales: (N, 3) float32 scale factors
Returns: (N, 4, 4) float32 model matrices (Translate * Rotate * Scale)