Try this to get a Transform3D that you can use to move your points. You can
then apply the transform to a TransformGroup to rotate you points. Similarly,
you can generate a Matrix3d and move the points before sending them to the
rendering pipeline. That may be more efficient (eg. change the geometry once
rather than compute a rotation every pass) depending on the circumstances.
Realize, this code is set up presuming the rotation is about the same origin
point as you used in your definition of the object endpoints. If the rotation
point is different you will observe some odd jumps in the view. That is easy
to fix by translation of the endpoints to the correct reference origin before
computing the rotation axis.
--------------------------------------------------------------------
//Define end points as new vectors
Vector3d fromDir = new Vector3d(fromPoint);
Vector3d toDir = new Vector3d(toPoint);
//Compute the value of the angle between them (no spatial orientation
info though)
double rotInRadians = fromDir.angle(toDir);
//Compute an orthagonal vector to later define the rotation axis
(orientation info)
Vector3d orthagonalAxis = new Vector3d();
orthagonalAxis.cross(fromDir, toDir);
orthagonalAxis.normalize();
//Create new rotation matrix
AxisAngle4d rotAxis = new AxisAngle4d(orthagonalAxis, rotInRadians);
Transform3D resultantTransform = new Transform3D();
resultantTransform.setRotation(rotAxis);
Hope this helps - Gary Graf
John Nelson wrote:
> All,
>
> I've run into a problem that neither the Java3d examples or the Sun API
> reference seem to be able to explain to me.... and that is how to perform
> rotation traansforms. All the examples I've seen either use a mouse event
> or an Alpha/Interpolator.... but all I want to do is just create a
> cylinder and rotate it to a specific orientation in three-space.
>
> Sounds pretty simple but I haven't been able to figure it out from the
> tools available.
>
> Now, I will tell you that I have tried creating a Maatrix3d, normalizing
> it and then doing rotX, rotY and rotZ and then pumping that into a
> Transform3d. But this doesn't actually seem to do anything.
>
> Can anyone post some example code or point me to the right place?
>
> -- John
>
> --
> _____________________________________________________
>
> John T. Nelson
> President | Computation.com Inc
> mail: | [EMAIL PROTECTED]
> company: | http://www.computation.com/
> journal of computation: | http://www.computation.org/
> _____________________________________________________
> "Providing quality IT consulting services since 1992"
>
> ===========================================================================
> 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".
===========================================================================
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".