com.hermetica.util3d
Class trackball

java.lang.Object
  |
  +--com.hermetica.util3d.trackball

public class trackball
extends java.lang.Object


Constructor Summary
trackball()
          Constructor
trackball(float size)
          Constructor with trackball size.
 
Method Summary
 float[] addQuats(float[] q1, float[] q2)
          Given two rotations, e1 and e2, expressed as quaternion rotations, figure out the equivalent single rotation and return it.
 float[] axisToQuat(float[] a, float phi)
          Given an axis and angle, compute the quaternion
 float[][] buildMatrix(float[] q)
          Builds a rotation matrix from a given quaternion
 float[] buildQuaternion(float p1x, float p1y, float p2x, float p2y)
          Calculates a quaternion representing the trackball
 float projectToSphere(float r, float x, float y)
          Project an x, y pair onto a sphere of radius r OR a hyperbolic sheet if we are away from the centre of the sphere.
 float[] renormalizeQuat(float[] q)
          Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

trackball

public trackball()
Constructor

trackball

public trackball(float size)
Constructor with trackball size. The default is 0.8
Method Detail

buildQuaternion

public float[] buildQuaternion(float p1x,
                               float p1y,
                               float p2x,
                               float p2y)
Calculates a quaternion representing the trackball

axisToQuat

public float[] axisToQuat(float[] a,
                          float phi)
Given an axis and angle, compute the quaternion

projectToSphere

public float projectToSphere(float r,
                             float x,
                             float y)
Project an x, y pair onto a sphere of radius r OR a hyperbolic sheet if we are away from the centre of the sphere.

addQuats

public float[] addQuats(float[] q1,
                        float[] q2)
Given two rotations, e1 and e2, expressed as quaternion rotations, figure out the equivalent single rotation and return it. This routine also normalizes the result every RENORMCOUNT times it is called to keep error from creeping in. NOTE: This routine is written so that q1 or q2 may be the same as dest ( or each other ).

renormalizeQuat

public float[] renormalizeQuat(float[] q)
Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0. If they don't add up to 1.0, dividing them by their magnitude will renormalize them.

buildMatrix

public float[][] buildMatrix(float[] q)
Builds a rotation matrix from a given quaternion