Example #1
0
/** @brief rotate in the given direction
 * @tparam VEC point type including POINT::Scalar as coord type
 * @param _direction vector which points in the desired direction
 */
template<class VEC> void glRotate(const VEC& _direction)
{
  // get coordinate type from vector type
  typedef typename VEC::scalar_type Scalar;
  // pre-calculate vector length
  Scalar length = _direction.length();
  // calculate phi and theta (@link http://de.wikipedia.org/wiki/Kugelkoordinaten#.C3.9Cbliche_Konvention)
  Scalar phi = tomo::rad2deg( atan2(_direction.y(), _direction.x()) );
  Scalar theta = (0.0 != length) ? tomo::rad2deg(acos( (_direction.z() / length) )) : 0.0;
  // rotate GL world
  glRotate(phi,theta);
}