Skip to main content

Crate tpt_math_spatial

Crate tpt_math_spatial 

Source
Expand description

In-house (no external-crate) spatial kinematics for the tpt-math substrate: Featherstone 6-D spatial vectors, Plücker / adjoint transforms, dual quaternions and screw theory (exponential / logarithmic maps).

Everything is built on tpt_math_geometry (Isometry3, Quaternion, UnitQuaternion, …) and tpt_math_linalg_fixed, is #![no_std] and allocator-free (stack-allocated fixed-size storage), and carries no nalgebra dependency (matching the workspace license policy, ADR-0007). It exists to fill the spatial-algebra gap in-house.

§Conventions (stated explicitly)

  • Active (alibi) rotations — a transform acts on a vector v as R * v; the point/vector is rotated, not the coordinate frame.
  • Column vectors — transformations apply as M * v.
  • Right-handed coordinates — positive angle about +z rotates x → y; x × y = z.
  • Spatial (6-D) vectors are stored [angular (top 3); linear (bottom 3)]: a motion vector v = (ω, v) and a force/wrench f = (n, f) (moment, force).
  • Spatial cross product follows Featherstone’s crm / crf operators (see SpatialVector::cross and friends); the result kind is determined by the operand kinds (motion⊗motion→motion, motion⊗force→force, force⊗motion→force, force⊗force→motion).
  • Screw exponential exp maps a twist (ω, v) ∈ se(3) to an Isometry3; log is its inverse. The convention is the standard Lynch–Park se(3) exponential with an active, right-handed rotation.
  • Dual quaternions are Hamilton quaternions q + ε·qₑ representing a rigid transform (rotation quaternion + half the translation quaternion pre-multiplied by the rotation).

§Examples

use tpt_math_spatial::{MotionVector, Screw};
use tpt_math_geometry::{Isometry3, Rotation3, Translation};
use tpt_math_linalg_fixed::Vector3;

// A 90° active rotation about +Z.
let rot = Rotation3::from_axis_angle(&Vector3::new([0.0_f64, 0.0, 1.0]), std::f64::consts::FRAC_PI_2);
let iso = Isometry3::new(Translation::new(Vector3::new([0.0, 0.0, 0.0])), rot);

// A pure-linear motion (1,0,0): after the rotation its linear part is (0,1,0).
let m = MotionVector::new(Vector3::new([0.0, 0.0, 0.0]), Vector3::new([1.0, 0.0, 0.0]));
let m2 = m.transform_by(&iso);
assert!((m2.linear().x()).abs() < 1e-12);
assert!((m2.linear().y() - 1.0).abs() < 1e-12);

// A screw twist exponentiates to the same isometry.
let screw = Screw::new(Vector3::new([0.0, 0.0, std::f64::consts::FRAC_PI_2]), Vector3::new([0.0, 0.0, 0.0]));
let iso2 = screw.exp();
assert!((iso2.rotation.matrix().data[0][1] - (-1.0)).abs() < 1e-12);

Structs§

DualQuaternion
A dual quaternion q = real + ε·dual, each part a Hamilton Quaternion (w last). A unit dual quaternion represents a rigid transform (rotation + translation) with no scaling.
Force
Marker type for force-type spatial vectors (wrenches: moment + force).
Motion
Marker type for motion-type spatial vectors (velocities, accelerations).
Screw
A screw (twist) in se(3), stored as the 6-D spatial motion vector (ω, v) where ω is the angular part (rotation axis × angle) and v is the linear part.
SpatialVector
A 6-D spatial vector v = [angular (top 3); linear (bottom 3)], tagged by K ∈ {Motion, Force} to control cross-product and transform semantics (Featherstone’s crm / crf operators).

Functions§

adjoint_force
The force adjoint Ad_X* of an isometry (R, t):
adjoint_motion
The motion adjoint Ad_X of an isometry (R, t):

Type Aliases§

ForceVector
A force / wrench spatial vector (n, f).
Matrix6
A 6 × 6 matrix (fixed-size, row-major).
MotionVector
A motion spatial vector (ω, v).