00001 //============================================================================= 00002 /*! return quat from vec and real */ 00003 inline quat vr2q(const vec& v, const double& _r) 00004 { 00005 return quat(v.x, v.y, v.z, _r); 00006 } 00007 00008 //============================================================================= 00009 /*! return quat from vec and angle */ 00010 inline quat vt2q(const vec& v, const double& theta) 00011 { 00012 vec n(normal(v)); 00013 double sin_theta_half(std::sin(0.5*theta)); 00014 return quat( n.x*sin_theta_half, n.y*sin_theta_half, n.z*sin_theta_half, 00015 std::cos(0.5*theta) ); 00016 } 00017 00018 /////////////////////////////////////////////////////////////////////////////// 00019 /////////////////////////////////////////////////////////////////////////////// 00020 /////////////////////////////////////////////////////////////////////////////// 00021 00022 //============================================================================= 00023 /*! swap two vecs */ 00024 inline void swap(vec& v1, vec& v2) 00025 { 00026 vec _v1(v1); 00027 v1 = v2; 00028 v2 =_v1; 00029 }