Skip to main content

quat_to_rot4

Function quat_to_rot4 

Source
pub fn quat_to_rot4<const D: usize, const DR: usize>(q: Tensor<D>) -> Tensor<DR>
Expand description

Materialise the 4×4 orthogonal matrix of left-multiplication by q.

Maps q of shape [..., 4] to [..., 4, 4] such that, for v of shape [..., 4], Lq · v == quat_mul(q, v). Concretely (rows = output coords, cols = input coords, all in (w, x, y, z) order):

  ⎡ w  -x  -y  -z ⎤
  ⎢ x   w  -z   y ⎥
  ⎢ y   z   w  -x ⎥
  ⎣ z  -y   x   w ⎦

For a unit q this is orthogonal with det = 1 (a left-isoclinic rotation). Provided mainly for the generic / verification path; the cheap way to apply a rotation is rotate_state_rank_blocks (a quaternion product, no 4×4 materialisation). DR must equal D + 1.