* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
public class AltosQuaternion {
double r; /* real bit */
double x, y, z; /* imaginary bits */
public class AltosQuaternion {
double r; /* real bit */
double x, y, z; /* imaginary bits */
public AltosQuaternion multiply(AltosQuaternion b) {
return new AltosQuaternion(
this.r * b.r - this.x * b.x - this.y * b.y - this.z * b.z,
public AltosQuaternion multiply(AltosQuaternion b) {
return new AltosQuaternion(
this.r * b.r - this.x * b.x - this.y * b.y - this.z * b.z,
public AltosQuaternion rotate(AltosQuaternion b) {
return (b.multiply(this)).multiply(b.conjugate());
}
public AltosQuaternion rotate(AltosQuaternion b) {
return (b.multiply(this)).multiply(b.conjugate());
}
public AltosQuaternion vectors_to_rotation(AltosQuaternion b) {
/*
* The cross product will point orthogonally to the two
public AltosQuaternion vectors_to_rotation(AltosQuaternion b) {
/*
* The cross product will point orthogonally to the two
return new AltosQuaternion(1, 0, 0, 0);
}
return new AltosQuaternion(1, 0, 0, 0);
}
- static public AltosQuaternion half_euler(double x, double y, double z) {
+ static public AltosQuaternion euler(double x, double y, double z) {
+
+ /* Halve the euler angles */
+ x = x / 2.0;
+ y = y / 2.0;
+ z = z / 2.0;
+
double s_x = Math.sin(x), c_x = Math.cos(x);
double s_y = Math.sin(y), c_y = Math.cos(y);
double s_z = Math.sin(z), c_z = Math.cos(z);;
double s_x = Math.sin(x), c_x = Math.cos(x);
double s_y = Math.sin(y), c_y = Math.cos(y);
double s_z = Math.sin(z), c_z = Math.cos(z);;