they may (Free web design) be considered to add an additional
they may be considered to add an additional rotation angle to spherical coordinates: longitude, latitude, and rotation angles. A Quaternion is defined using four floating point values |x y z w|. These are calculated from the combination of the three coordinates of the rotation axis and the rotation angle. Unfortunately most people do not think readily in quaternions, so the following two conversion functions are useful to help create quaternions from axis or Euler angles. The algorithms for the functions were taken from the Matrix and Quaternion FAQ. I encourage you to check the FAQ for updates, optimizations and corrections to this code. From InterpolatorTest.java //Quat4f createQuaternionFromAxisAndAngle //( Vector3d axis, double angle ) { double sin_a = Math.sin( angle / 2 ); double cos_a = Math.cos( angle / 2 ); //use a vector so we can call normalize Vector4f q = new Vector4f(); q.x = (float) (axis.x * sin_a); q.y = (float) (axis.y * sin_a); q.z = (float) (axis.z * sin_a); q.w = (float) cos_a; //It is best to normalize the quaternion //so that only rotation information is used q.normalize(); //convert to a Quat4f and return return new Quat4f( q ); } //Quat4f createQuaternionFromEuler( double angleX, //double angleY, double angleZ ) { //simply call createQuaternionFromAxisAndAngle for each axis //and multiply the results Quat4f qx = createQuaternionFromAxisAndAngle( new Vector3d(1,0,0), angleX ); Quat4f qy = createQuaternionFromAxisAndAngle( new Vector3d(0,1,0), angleY ); Quat4f qz = createQuaternionFromAxisAndAngle( new Vector3d(0,0,1), angleZ ); //qx = qx * qy qx.mul( qy ); //qx = qx * qz qx.mul( qz ); return qx; } 203
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.