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.

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.

API

simvx.core.helpers.mat4_from_trs(pos: tuple[float, float, float] | numpy.ndarray, rot, scl: tuple[float, float, float] | numpy.ndarray) numpy.ndarray

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.mat4_to_bytes(m: numpy.ndarray) bytes

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

Run multiple coroutines simultaneously, finish when all complete.

simvx.core.helpers.wait(seconds: float) simvx.core.descriptors.Coroutine

Pause a coroutine for given seconds.

simvx.core.helpers.wait_until(condition: collections.abc.Callable[[], bool]) simvx.core.descriptors.Coroutine

Yield until condition() returns True.

simvx.core.helpers.wait_signal(signal: simvx.core.descriptors.Signal) simvx.core.descriptors.Coroutine

Yield until signal is emitted. Returns signal args.

simvx.core.helpers.next_frame() simvx.core.descriptors.Coroutine

Yield for exactly one frame.

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

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)

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