Skip to main content

bound_rotation_vector

Function bound_rotation_vector 

Source
pub fn bound_rotation_vector<const D: usize>(
    r: Tensor<D>,
    max_angle: f64,
) -> Tensor<D>
Expand description

Bound a rotation vector’s magnitude, leaving its direction alone: returns max_angle · tanh(‖r‖) · r̂.

This is the quaternion counterpart of the abelian path’s π·tanh(ϑ), and the difference is deliberate. Squashing each of the three raw channels separately would bound the rotation vector to a cube: the reachable angle would depend on the axis (max_angle about a coordinate axis but √3·max_angle about the diagonal), and — worse — tanh applied per component moves the direction too, so the axis a given projection selects would depend on how large the projection is. Bounding the norm keeps the axis exactly and the angle a function of ‖r‖ alone, so axis and angle are independent knobs.

Near r = 0 the map is ≈ max_angle · r (the tanh(n)/n → 1 limit); the sum-of-squares floor is the same pre-sqrt clamp quat_from_scaled_axis uses, and puts the degenerate point in the flat region of clamp_min with the correct finite gradient.

§Shapes

  • r : [..., 3]
  • out : [..., 3], with ‖out‖ ≤ max_angle (attained once tanh saturates).