Hello,
I have found difficulty with the
setEuler(Vector3D) method. I found that it did not reflect exactly the motions
that I expected, or needed to reproduce. didn't investigate very far, because I
found something similar to what David Halle used. Here's what I use to get 6
degrees of motion for ship hulls.
Motion motion = (Motion)motions.get(index); // retrieves
a single motion slice with 6
degrees....
float roll = motion.getRoll();
float pitch = motion.getPitch();
float yaw = motion.getYaw();
float heave = motion.getHeave();
float sway = motion.getSway();
float surge = motion.getSurge();
// STEP 2 CREATE THE ROTATION MATRIX
// Create a matrix corresponding to roll pitch and yaw
Matrix3f mat1 = new Matrix3f();
mat1.rotX(Math.toRadians(roll));
Matrix3f mat2 = new Matrix3f();
mat2.rotY(Math.toRadians(pitch));
Matrix3f mat3 = new Matrix3f();
mat3.rotZ((Math.toRadians(yaw));
// combine roll pitch yaw matrices
mat1.mul(mat2);
mat1.mul(mat3);
//STEP 3 CREATE THE TRANSLATION VECTOR
Vector3f vec = new Vector3f(surge,sway,heave);
// STEP 4 COMBINE INTO ONE TRANSFORM AND SET IN HULLTG
float roll = motion.getRoll();
float pitch = motion.getPitch();
float yaw = motion.getYaw();
float heave = motion.getHeave();
float sway = motion.getSway();
float surge = motion.getSurge();
// STEP 2 CREATE THE ROTATION MATRIX
// Create a matrix corresponding to roll pitch and yaw
Matrix3f mat1 = new Matrix3f();
mat1.rotX(Math.toRadians(roll));
Matrix3f mat2 = new Matrix3f();
mat2.rotY(Math.toRadians(pitch));
Matrix3f mat3 = new Matrix3f();
mat3.rotZ((Math.toRadians(yaw));
// combine roll pitch yaw matrices
mat1.mul(mat2);
mat1.mul(mat3);
//STEP 3 CREATE THE TRANSLATION VECTOR
Vector3f vec = new Vector3f(surge,sway,heave);
// STEP 4 COMBINE INTO ONE TRANSFORM AND SET IN HULLTG
//
an alternative would be to get the Transform from the TG and reset the
values...
Transform3D next = new Transform3D(mat1,vec,1.0f); // 1.0f = scale..
hullTG.setTransform(next);
Transform3D next = new Transform3D(mat1,vec,1.0f); // 1.0f = scale..
hullTG.setTransform(next);
Just another idea....
Cheers,
B.
-----------------------------------------------------
Oceanic Consulting Corporation
P.O. Box 28009
St. John's, NF,
Canada
A1B 4J8
(709) 722-9060/9064(fax) http://www.oceaniccorp.com
-----------------------------------------------------
-----Original Message----->If you multiply seperate rotations, the second rotation will use the
From: David Hall� [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 11, 2000 5:14 AM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] rotX and rotY
>resulting object of the first rotation.
>If however you want to do several rotations at once, e.g. roll/pitch/yaw for
>an aircraft, you should use the
>Transform3D.setEuler(Vector3d) method.I use the roll/pitch/yaw for an aircraft (ie. a transformgroup) like this:
// T is the current Transform3D for my TransformGroup
public void rotate(double[] rotationAngles) {
Transform3D temp = new Transform3D();
temp.rotY(rotationAngles[0]);
T.mul(temp);
temp.rotZ(rotationAngles[1]);
T.mul(temp);
temp.rotX(rotationAngles[2]);
T.mul(temp);
setTransform(T);
}David.
