simvx.core.helpers

Matrix helpers, coroutine helpers, easing functions, and raycasting utilities.

Module Contents

Functions

mat4_from_trs

Build model matrix from position, rotation quaternion, and scale.

batch_mat4_from_trs

Build N model matrices from arrays of positions, quaternions, and scales.

mat4_to_bytes

Convert mat4 to bytes for GPU upload.

parallel

Run multiple coroutines simultaneously, finish when all complete.

wait

Pause a coroutine for given seconds.

wait_until

Yield until condition() returns True.

wait_signal

Yield until signal is emitted. Returns signal args.

next_frame

Yield for exactly one frame.

ease_in_quad

ease_out_quad

ease_in_out_quad

ease_in_cubic

ease_out_cubic

screen_to_ray

Convert a screen pixel coordinate to a world-space ray (origin, direction).

ray_intersect_sphere

Ray-sphere intersection. Returns distance t or None if no hit.

Data

log

API

simvx.core.helpers.log[source]

‘getLogger(…)’

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.

simvx.core.helpers.ease_in_quad(t)[source]
simvx.core.helpers.ease_out_quad(t)[source]
simvx.core.helpers.ease_in_out_quad(t)[source]
simvx.core.helpers.ease_in_cubic(t)[source]
simvx.core.helpers.ease_out_cubic(t)[source]
simvx.core.helpers.screen_to_ray(screen_pos, screen_size, view, proj)[source]

Convert a screen pixel coordinate to a world-space ray (origin, direction).

Returns (origin, direction) as Vec3.

simvx.core.helpers.ray_intersect_sphere(origin, direction, center, radius: float)[source]

Ray-sphere intersection. Returns distance t or None if no hit.