예제 #1
0
/**
 * Generate the rotation matrix to rotate to this point.
 * @param a :: The x mouse coordinate
 * @param b :: The y mouse coordinate
 */
void Viewport::generateRotationTo(int a,int b)
{
  Mantid::Kernel::V3D newpoint;
  projectOnSphere( a, b, newpoint );
  Mantid::Kernel::V3D diff( m_lastpoint );
  // Difference between old point and new point
  diff -= newpoint;
  // Angle is given in degrees as the dot product of the two vectors
  double angle = m_rotationspeed * newpoint.angle( m_lastpoint );
  diff = m_lastpoint.cross_prod( newpoint );
  // Create a quaternion from the angle and vector direction
  Mantid::Kernel::Quat temp( angle, diff );
  // Left multiply
  temp *= m_quaternion;
  // Assignment of _quaternion
  m_quaternion( temp );
  // Get the corresponding OpenGL rotation matrix
  m_quaternion.GLMatrix( &m_rotationmatrix[0] );
}
예제 #2
0
/**
 * Start a trackball rotation from here.
 * @param a :: The x mouse coordinate
 * @param b :: The y mouse coordinate
 */
void Viewport::initRotationFrom(int a,int b)
{
  projectOnSphere(a,b,m_lastpoint);
}
예제 #3
0
void GLTrackball::initRotationFrom(int a,int b)
{
  projectOnSphere(a,b,_lastpoint);
}