Skip to content

novaphy.math

Spatial algebra primitives, axis / angle conversions, and a couple of vertex-batch helpers. These symbols live at the top level of novaphy; they are grouped here to mirror newton.math.

Spatial Vector Convention

NovaPhy spatial-algebra helpers use Newton-compatible, linear-first 6D vectors.

6D quantity Layout Used by
Spatial velocity / twist [v_x, v_y, v_z, ω_x, ω_y, ω_z] Internal articulated-body kernels, spatial helpers, and free-joint joint_qd slices
Spatial force / wrench [f_x, f_y, f_z, τ_x, τ_y, τ_z] Spatial helpers and internal articulated-body kernels
Spatial inertia 6×6 symmetric matrix spatial_inertia_matrix

The flat rigid-body state views use the same component order: state.body_qd[i] == [vx, vy, vz, wx, wy, wz] and state.body_f[i] == [fx, fy, fz, tx, ty, tz].

The functions in this namespace are mostly used internally by the Featherstone solver and articulation evaluators (eval_fk, eval_jacobian, eval_mass_matrix, …). External code typically only needs them when implementing custom articulated dynamics on top of NovaPhy primitives. The C++ SimState::apply_articulation_force helper is not exposed in Python; Python callers apply body forces and torques with state.apply_force(...) and state.apply_torque(...).

Quaternion Convention

Python-facing quaternion arrays use [qx, qy, qz, qw] (Hamilton convention, xyzw order), matching Newton and Eigen::Quaternionf::coeffs(). In C++, Eigen's quaternion constructor still takes arguments as (w, x, y, z). Free-joint generalized positions include a quaternion in the Python-facing layout:

  • q for a Free joint: [px, py, pz, qx, qy, qz, qw] (7 elements)
  • qd for a Free joint: [vx, vy, vz, wx, wy, wz] in Python-facing flat buffers (linear first, matching Newton's flat layout)

Spatial Algebra

Function Description
skew() Skew-symmetric matrix from a 3D vector.
spatial_cross_force() Featherstone spatial cross product (motion-on-force).
spatial_cross_motion() Featherstone spatial cross product (motion-on-motion).
spatial_inertia_matrix() Build a 6x6 spatial inertia matrix from mass, COM, and inertia tensor.

Angle Helpers

Function Description
axis_to_vec3() Convert an Axis enum to a 3D unit vector.
deg2rad() Degrees → radians.
rad2deg() Radians → degrees.

Geometry Helpers

Function Description
batch_transform_vertices() Transform indexed batches of local vertices into a preallocated world-space buffer.

Compatibility Notes

Newton's newton.math Warp-friendly numerics suite is not provided. Items not yet available include:

  • safe_div, smooth_min, smooth_max, differentiable_min, differentiable_max, boltzmann
  • Quaternion utilities (quat_between_vectors, quat_to_euler, quat_velocity, quat_basis_vector_rotation)
  • Vector helpers (vec3_abs, vec_max, vec_min, vec_max_leaky, vec_min_leaky, vec_allclose, vec_inside_limits)
  • Frame transforms (transform_twist, transform_wrench, velocity_at_point)
  • normalize_unit_vector, orthonormal_basis_from_normal