Hello,
I believe I may be confused. I'm having trouble agreeing with this:
> The code in the messge below will translate the object to
> 20,20,20 and then
> rotate the translated object around the origin (that is, it won't
> rotate around
> it's center, it will "orbit" the origin by the specified
> rotation).
Perhaps its merely what we are calling an object. I interpret an "object"
essentially being a transform group.
I made a a class that extended TransformGroup that had the following method
in it:
public void rotZmore(double angle) {
Transform3D my_t3d=new Transform3D(); //a place to store the
Transform3D
of the TransformGroup
this.getTransform(my_t3d);
Vector3d my_vector=new Vector3d(); //a place to
store the Translation
coordinates of the T.G.
my_t3d.get(my_vector);
//Next, I just want to see what those coordinates are before I
rotate
System.out.println("x="+my_vector.x+" y="+my_vector.y+"
z="+my_vector.z);
Transform3D my_other3d=new Transform3D(); //a Transform3D to
hold my
desired rotation description
my_other3d.set(new AxisAngle4d(0.0,0.0,1.0,-angle)); //Simply
setting my
rotation
my_t3d.mul(my_other3d); //performing
the desired rotation on the
original Transform3d
my_t3d.get(my_vector); //Getting the
new coordinates after the
rotation
//Will
they change? That is the question:
//Show if the coordinates after rotation - should they change?
System.out.println("x="+my_vector.x+" y="+my_vector.y+"
z="+my_vector.z);
this.setTransform(my_t3d); //set the
Transform3D to our new rotation
}
What this does is rotates the TransformGroup about "its" Z axis. According
to the commented text, my translation coordinates should have changed when I
do the rotation and the object should have rotated about the origin of the
Group that this TransformGroup is attached to.
However, they do not. The transform group rotates around its center. The
translation coordinates reflect the x, y, z within the transformgroup that
it is attached to. The System.out.println statements return the same
coordinates before and after the rotation. In addition, they are the
location of the center of the object (a cylinder). Of course, all this is
verified visually by the program.
So, it seems that this code translates the transform group to x, y, z and
then rotates about "its" center (not about the origin of the group that its
attached to):
> > You need to multiply the matrices into a result. Try this:
> >
> > Transform3D result = new Transform3D();
> > Transform3D temp = new Transform3D();
> > result.setTranslation(new Vector3d(20, 20, 20)); // set
translation
> > temp.set(new AxisAngle4d(1.0, 0.0, 0.0, toRadians(-45)));
> > result.mul(temp); // post-concatinate rotation
> > temp.set(new AxisAngle4d(0.0, 1.0, 0.0, toRadians(45)));
> > result.mul(temp);
> >
> > transformGroup.setTransform(result);
> >
> >
Please try to clear this up for me. I've been struggling with an easier way
to solve a similar problem for two weeks now.
Thanks,
Sean
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/