How to Convert "quat to vec" and "vec to quat"


vec im(const quat & q)
Pull out the imaginary part of q, and put it into v.

v =im(q);

\[ \overrightarrow{v}= \left\{ q_x, q_y, q_z \right\} \]


quat vr2q(const vec & v, const double & r)
Put v into im(q), and put r into q.r .

q =vr2q(v,r);

\[ \mathbf{q}= \left[ v_x, v_y, v_z; r \right] \]


quat vt2q(const vec & u, const double & phi) The rotation quaternion, which axis direction is v and angular is theta.

q =vt2q(u,phi);

\[ \mathbf{q} = \left[ \frac{{u_x}}{|\vec{u}|}\sin \left( \frac{\phi}{2} \right), \frac{{u_y}}{|\vec{u}|}\sin \left( \frac{\phi}{2} \right), \frac{{u_z}}{|\vec{u}|}\sin \left( \frac{\phi}{2} \right); \cos \left( \frac{\phi}{2} \right) \right] \]

Generated on Tue Mar 15 16:02:38 2005 for QVM by  doxygen 1.4.1