quat-misc.hpp File Reference

Go to the source code of this file.

Functions

vec im (const quat &q)
vec q2vt (const quat &q)
quat conj (const quat &q)
void swap (quat &q1, quat &q2)


Function Documentation

vec im const quat q  )  [inline]
 

return the imaginary part

Definition at line 3 of file quat-misc.hpp.

Referenced by orbit(), and rotate().

00004 {
00005   return vec( q.x, q.y, q.z );
00006 }

vec q2vt const quat q  )  [inline]
 

return vec from quat (|vec|=theta)

Definition at line 10 of file quat-misc.hpp.

00011 {
00012   double sin_theta_half;
00013   double theta( 2.*std::acos(q.r) );
00014   
00015   if(theta<M_PI){
00016     sin_theta_half =std::sin(0.5*theta);
00017   }
00018   else{
00019     theta -=2.*M_PI;
00020     sin_theta_half =-std::sin(0.5*theta);
00021   }
00022   
00023   return vec( theta*q.x/sin_theta_half,
00024               theta*q.y/sin_theta_half,
00025               theta*q.z/sin_theta_half );
00026 }

quat conj const quat q  )  [inline]
 

return the conjugate quat

Definition at line 34 of file quat-misc.hpp.

Referenced by inv(), orbit(), and rotate().

00035 {
00036   return quat( -q.x, -q.y, -q.z, q.r );
00037 }

void swap quat q1,
quat q2
[inline]
 

swap two quats

Definition at line 45 of file quat-misc.hpp.

00046 {
00047   quat _q1(q1);
00048   q1 = q2;
00049   q2 =_q1;
00050 }


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