To compute the quaternion associated to the direction of a line from P1=[x1,y1,z1] to P2=[x2,y2,z2]
I am using the following method:
public Quat4f quaternion(double x1, double y1, double z1, double x2,
double y2, double z2)
{
//--- Euler angles:
double phy = Math.atan((y2-y1)/(x2-x1));
double theta = Math.atan((x2-x1)/(z2-z1));
double psi = Math.atan((z2-z1)/(y2-y1));
//---
float w = (float)(Math.cos(psi/2)*Math.cos(theta/2)*Math.cos(phy/2)
+
Math.sin(psi/2)*Math.sin(theta/2)*Math.sin(phy/2));
float x = (float)(Math.sin(psi/2)*Math.cos(theta/2)*Math.cos(phy/2)
-
Math.cos(psi/2)*Math.sin(theta/2)*Math.sin(phy/2));
float y = (float)(Math.cos(psi/2)*Math.sin(theta/2)*Math.cos(phy/2)
+
Math.sin(psi/2)*Math.cos(theta/2)*Math.sin(phy/2));
float z = (float)(Math.cos(psi/2)*Math.cos(theta/2)*Math.sin(phy/2)
-
Math.sin(psi/2)*Math.sin(theta/2)*Math.cos(phy/2));
return new Quat4f(x, y, z, w);
}
Aluizio Arcela
Universidade de Brasilia
Richard Ems wrote:
Hi,I know this question appeared a couple of months ago on the list (yes, I
searched the archive!) but still no precise answer was posted!What describe the quaternions in RotPosPathInterpolator ?
Is it an axis and the rotation around that axis (in radians) ?
Or the rotation around each axis?
What's the first value w in the quaternion ?What is the axisOfRotPos ?
Thanks for any help !
--
Richard Ems
... e-mail: [EMAIL PROTECTED]
... Fachbereich Informatik, Universität HamburgUnix IS user friendly. It's just selective about who its friends are.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
