vecn<3, COMP_T>::vecn(vecn<3, OTHER_COMP_T> const& rhs) { set( static_cast<COMP_T>(rhs.x()), static_cast<COMP_T>(rhs.y()), static_cast<COMP_T>(rhs.z()) ); }
void rot(const vecn<T,3>& n,const T& t) { if( t != T(0) && ( n.x() != T(0) || n.y() != T(0) || n.z() != T(0) ) ) { //assert(n.length()); m_quat *= Quaternion<T>(n,t); m_cache.invalidate(); m_inv_cache.invalidate(); } }
void look_at(vecn<T,3> dir,vecn<T,3> up) { std::cout<<"utk::inertial::look_at\t|dir\t"<<dir<<"\t|up\t"<<up<<std::endl; dir.normalize(); up.normalize(); //assert(fabs(dot(dir,up))<std::numeric_limits<T>::epsilon()*10.); veca<T,3> right(cross(dir,up)); mata<T,3> m; m[0]=right; m[1]=up; m[2]=-dir;//you look along the z-axis in negative direction std::clog << "utk::inertial::look_at\t|" << " " << Quaternion<T>(m) << std::endl; std::clog << "utk::inertial::look_at\t|" << " x " << m[0] << " y " << m[1] << " z " << m[2] << std::endl; orientation<T>::quat() = Quaternion<T>(m); }
veca<T,3> inv_rot_vec(const vecn<T,3>& v) const { veca<T,3> qres( m_quat * Quaternion<T>(v.x(),v.y(),v.z(),T(0)) * m_quat.conjugated() ); return qres; }