LWJGL
May 23, 2013, 14:31:36 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL is now using GitHub
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: ArcBall  (Read 2731 times)
wmjoers
Newbie
*
Posts: 7


WWW
« on: July 10, 2005, 23:38:21 »

Has anyone implemented the ArcBall class using the Quaternion and Vector classes in  LWJGL???
Logged
wmjoers
Newbie
*
Posts: 7


WWW
« Reply #1 on: July 11, 2005, 07:28:42 »

Another question....

The Quaternion class has a method called .setFromAxisAngle(Vector4f a1)
...shouldn't there be a .toAxisAngle(...) as well?

...or can you obtain that vector in some other way?
Logged
DeX
Newbie
*
Posts: 15


« Reply #2 on: September 14, 2005, 02:29:47 »

I agree, there should be a toAxisAngle function. Instead I am doing this process manually:

Code:

float ax, ay, az;
float quatScale = (float)Math.sqrt(quat.getX()*quat.getX() + quat.getY()*quat.getY() + quat.getZ()*quat.getZ());
float quatAngle;
if (quatScale == 0) { //no rotation
ax = 1; ay = 0; az = 0;
quatAngle = 0;
}else{
ax = quat.getX() / quatScale;
ay = quat.getY() / quatScale;
az = quat.getZ() / quatScale;
quatAngle = 2 * (float)Math.acos(quat.getW());
}


The axis is stored in ax, ay and az and the angle in quatAngle.

It would be really nice if someone could optimise this code and put it into a function for the Quaternion class. Anyone?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!