SpatialVec

Trait SpatialVec 

Source
pub trait SpatialVec: Sized {
    type DualType: SpatialVec;

    // Required methods
    fn from_pair(top: Vec3, bottom: Vec3) -> Self;
    fn top(&self) -> Vec3;
    fn bottom(&self) -> Vec3;

    // Provided methods
    fn dot(&self, rhs: &Self::DualType) -> Real { ... }
    fn cross_dual(&self, rhs: &Self::DualType) -> Self::DualType { ... }
    fn transpose(&self) -> Self::DualType { ... }
}
Expand description

Trait defining the core interface for spatial vectors in Featherstone’s spatial algebra.

§Spatial Vector Duality

In Featherstone’s formulation, spatial vectors come in dual pairs:

  • Motion vectors (velocity, acceleration): [ω, v] where ω is angular velocity and v is linear velocity
  • Force vectors (force, torque): [n, f] where n is moment/torque and f is force

This duality is fundamental to spatial algebra:

  • Motion and force vectors are duals of each other
  • The dot product between a motion vector and force vector gives power
  • Cross products have specific meanings for each combination

§Mathematical Conventions

Motion Vector:  v = [ω]  (angular velocity)
                     [v]  (linear velocity)

Force Vector:   f = [n]  (moment/torque)
                     [f]  (force)

Power:          P = v ⋅ f = ω·n + v·f

Required Associated Types§

Source

type DualType: SpatialVec

The dual type of this spatial vector.

For SpatialMotionVector, this is SpatialForceVector. For SpatialForceVector, this is SpatialMotionVector. This enforces type safety at compile time to prevent mixing incompatible vector types in operations.

Required Methods§

Source

fn from_pair(top: Vec3, bottom: Vec3) -> Self

Create a spatial vector from its top and bottom 3D components.

§Arguments
  • top - The angular component (ω for motion, n for force)
  • bottom - The linear component (v for motion, f for force)
Source

fn top(&self) -> Vec3

Get the top (angular) 3D component of the spatial vector.

  • For motion vectors: returns angular velocity ω
  • For force vectors: returns moment/torque n
Source

fn bottom(&self) -> Vec3

Get the bottom (linear) 3D component of the spatial vector.

  • For motion vectors: returns linear velocity v
  • For force vectors: returns force f

Provided Methods§

Source

fn dot(&self, rhs: &Self::DualType) -> Real

Calculate the dot product with the dual vector type.

This computes the scalar product between a motion vector and force vector, which represents power in physics: P = ω·n + v·f

§Mathematical Meaning

For motion vector v = [ω, v] and force vector f = [n, f]:

v ⋅ f = ω·n + v·f

where:

  • ω·n is the power from rotational motion
  • v·f is the power from linear motion
Source

fn cross_dual(&self, rhs: &Self::DualType) -> Self::DualType

Calculate the cross product with the dual vector type.

This operation represents the spatial cross product between motion and force vectors, following Featherstone’s spatial algebra conventions.

§Mathematical Formulation

For motion vector m = [ω, v] and force vector f = [n, f]:

m ×* f = [ω×n + v×f]
        [ω×f      ]

where ×* denotes the spatial cross product.

This operation is used in dynamics calculations, particularly for transforming forces between rotating reference frames.

Source

fn transpose(&self) -> Self::DualType

Compute the transpose (dual) of the spatial vector.

In spatial algebra, the transpose operation converts between motion and force vectors, effectively changing the vector’s interpretation while preserving its components.

§Mathematical Meaning

This is equivalent to the adjoint operation in spatial algebra, which is used for coordinate transformations and energy calculations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§