FreeHEP API
Version current

org.freehep.graphics3d
Class ArcBallMath

java.lang.Object
  extended byorg.freehep.graphics3d.ArcBallMath

public class ArcBallMath
extends Object

Original ArcBall C code from Ken Shoemake, Graphics Gems IV, 1993.

Version:
$Id: ArcBallMath.java,v 1.3 2002/12/13 17:40:48 duns Exp $
Author:
Mark Donszelmann
Source Code:
ArcBallMath.java

Method Summary
static Quaternion axisToQuaternion(Vector3 axis, double phi, Quaternion r)
          Given an axis and angle, compute quaternion, return null if axis cannot be normalized
static Quaternion buildQuaternion(double size, Vector3 from, Vector3 to, Quaternion r)
          Ok, simulate a track-ball.
static Vector3 constrainToAxis(Vector3 loose, Vector3 axis, Vector3 onPlane)
          return sphere point to be perpendicular to axis.
static int nearestConstraintAxis(Vector3 loose, Vector3[] axes)
           
static Vector3 projectToSphere(double r, double x, double y, Vector3 v)
          Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet if we are away from the center of the sphere.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

projectToSphere

public static Vector3 projectToSphere(double r,
                                      double x,
                                      double y,
                                      Vector3 v)
Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet if we are away from the center of the sphere. Return a vector.


constrainToAxis

public static Vector3 constrainToAxis(Vector3 loose,
                                      Vector3 axis,
                                      Vector3 onPlane)
return sphere point to be perpendicular to axis.


nearestConstraintAxis

public static int nearestConstraintAxis(Vector3 loose,
                                        Vector3[] axes)
Returns:
the index of nearest arc of axis set, or -1 if no axes supplied

buildQuaternion

public static Quaternion buildQuaternion(double size,
                                         Vector3 from,
                                         Vector3 to,
                                         Quaternion r)
Ok, simulate a track-ball. Project the points onto the virtual trackball, then figure out the axis of rotation, which is the cross product of P1 P2 and O P1 (O is the center of the ball, 0,0,0) Note: This is a deformed trackball-- is a trackball in the center, but is deformed into a hyperbolic sheet of rotation away from the center. This particular function was chosen after trying out several variations.

It is assumed that the arguments to this routine are in the range (-1.0 ... 1.0)

Returns:
quaternion or null, if axis length equals 0;

axisToQuaternion

public static Quaternion axisToQuaternion(Vector3 axis,
                                          double phi,
                                          Quaternion r)
Given an axis and angle, compute quaternion, return null if axis cannot be normalized


FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.