unilab.utils.geometry¶
Standalone numpy helpers for coordinate frames and geometry.
Reusable pure-numpy helpers for rotations, coordinate-frame transforms,
and geometric conversions. Kept dtype-agnostic and side-effect-free so
that env / task / backend code can compose them without carrying task
policy inside a shared module. Complements the vectorized quaternion
primitives in unilab.utils.rotation.
Functions
|
Z component of world gravity |
|
Return a unit-length copy of a rotation axis vector. |
|
Angular velocity from two consecutive quaternions via axis-angle diff / dt. |
|
Roll and pitch (rad) from a w-first quaternion, computed via rotation-matrix rows. |
|
Sample uniformly from |
|
Sample uniformly random unit quaternions (w-first) via Shoemake (1992). |
- unilab.utils.geometry.np_sample_uniform(lower, upper, size, dtype=<class 'numpy.float32'>)[source]¶
Sample uniformly from
[lower, upper]and cast todtype.
- unilab.utils.geometry.np_normalize_axis(axis)[source]¶
Return a unit-length copy of a rotation axis vector. Raises on zero norm.
- unilab.utils.geometry.np_roll_pitch_from_quat(quat)[source]¶
Roll and pitch (rad) from a w-first quaternion, computed via rotation-matrix rows.
Supports either
(4,)or(..., 4)inputs. Returned arrays match the caller’s leading shape and dtype (no upcast).
- unilab.utils.geometry.np_gravity_z_in_body_from_quat(quat_w)[source]¶
Z component of world gravity
[0, 0, -1]expressed in body frame.Equivalent to
np_quat_apply_inverse(quat_w, [0, 0, -1])[..., 2]but computed directly from quaternion components to skip the intermediate.