# rotation2quat¶

Given a rotation matrix $$C^{AB}$$ rotating the frame A onto B, the function returns the minimal “positive angle” quaternion representing this rotation, where the quaternion, $$\vec{\chi}$$ is defined as:

$\vec{\chi}= \left[\cos\left(\frac{\psi}{2}\right),\, \sin\left(\frac{\psi}{2}\right)\mathbf{\hat{n}}\right]$
param Cab

rotation matrix $$C^{AB}$$ from frame A to B

type Cab

np.array

returns

equivalent quaternion $$\vec{\chi}$$

rtype

np.array

Notes

This is the inverse of algebra.quat2rotation for Cartesian rotation vectors associated to rotations in the range $$[-\pi,\pi]$$, i.e.:

fv == algebra.rotation2crv(algebra.crv2rotation(fv))

where fv represents the Cartesian Rotation Vector, $$\vec{\psi}$$ defined as:

$\vec{\psi} = \psi\,\mathbf{\hat{n}}$

such that $$\mathbf{\hat{n}}$$ is a unit vector and the scalar $$\psi$$ is in the range $$[-\pi,\,\pi]$$.