simvx.core.helpers¶
Matrix helpers, coroutine helpers, easing functions, and raycasting utilities.
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. |
|
Run multiple coroutines simultaneously, finish when all complete. |
|
Pause a coroutine for given seconds. |
|
Yield until condition() returns True. |
|
Yield until signal is emitted. Returns signal args. |
|
Yield for exactly one frame. |
|
Convert a screen pixel coordinate to a world-space ray (origin, direction). |
|
Ray-sphere intersection. Returns distance t or None if no hit. |
Data¶
API¶
- simvx.core.helpers.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.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)
- simvx.core.helpers.mat4_to_bytes(m: numpy.ndarray) bytes[source]¶
Convert mat4 to bytes for GPU upload.
Args: m: 4x4 numpy matrix
Returns: 64 bytes (row-major float32)
- simvx.core.helpers.parallel(*coroutines: simvx.core.descriptors.Coroutine) simvx.core.descriptors.Coroutine[source]¶
Run multiple coroutines simultaneously, finish when all complete.
- simvx.core.helpers.wait(seconds: float) simvx.core.descriptors.Coroutine[source]¶
Pause a coroutine for given seconds.
- simvx.core.helpers.wait_until(condition: collections.abc.Callable[[], bool]) simvx.core.descriptors.Coroutine[source]¶
Yield until condition() returns True.
- simvx.core.helpers.wait_signal(signal: simvx.core.descriptors.Signal) simvx.core.descriptors.Coroutine[source]¶
Yield until signal is emitted. Returns signal args.
- simvx.core.helpers.next_frame() simvx.core.descriptors.Coroutine[source]¶
Yield for exactly one frame.