Assuming the that the two points you are talking about are going to be the
centers of the top and bottom of the cylinder (this also means the
cylinder's height must be the same as the Pythagorean distance between the
points) then I would attack the problem like this:

Knowing the two points, subtract on set from the corresponding elements in
the other set.  You now have a point that you can use as a vector whose
tail is anchored at the origin.

Knowing this vector, you should be able to get the rotations.  I don't know
how to do this as I have never done it but I am certain it can be
done.  Maybe someone out there can help.

Once you have the rotation matrix of the vector, you move the cylinder to
the point you subtracted from the other (a transformation) and you set the
rotation matrix to that which you got from the vector.

You now have a cylinder which has its bottom surface centered on one of
your points and because of the rotation, the top surface's center should
fall on the second point.


As for getting the rotation angles or rotation matrix of a vector, I have
been thinking about it and I have an idea.
Hopefully someone who has done this can jump in but I think there is a way
to get the angles from the vector using the angle() method of a vector type.

Suppose you have a vector whose tail is (0,0,0) and head is at (1,1,1), as
simple example.  So its vector3d is (1.0,1.0,1.0) and lets call it
Vector_Orig.  To get the rotation around the X axis, you find the
projection of the vector onto the XZ plane.  Mind you that you have to pick
a system and be consistent.  You will also have to deal with quadrants
other than the one into which everything is positive as I am doing with the
example (1.0,1.0,1.0) vector.

So let's say finding the projection of Vector_Orig (1.0,1.0,1.0) in the XZ
plane.  This would be (1.0,1.0,1.0) which we will call Vector_ProjXZ.

To get this angle  you use the angle() method of Vector3d.

angle_around_Zaxis = Vector_Orig.angle(Vector_ProjXZ);
(This angle should end up being negative.)

I don't recall if I am doing projections correctly but the magnitudes of
the vectors shouldn't matter since we are only interested in the angles and
they will not be affected by the magnitudes of the vectors.

You repeat this for the only one other projection, you shouldn't need all
three.

Vector_ProjYZ = (0.0,1.0,1.0)

angle_around_Yaxis = Vector_Orig.angle(Vector_ProjYZ);

I based this on a vector like this (0.0,0.0,1.0) that gets rotated around
the X axis (my guess is negative direction for this example) by
angle_around_Zaxis and then rotated around the Y axis by angle_around_Yaxis.

This should result in a vector that is the same as (1.0,1.0,1.0).

A bit tedious and even more so when you consider any special conditions for
all eight quadrants but it is do-able.

If someone out there thinks this is wrong or has a better idea, please jump in.





At 10:54 PM 09/30/2001 -0400, you wrote:
>Nope.... this isn't what I've said.  I have as a starting point, a pair of
>points in space that define the orientation of an object.  Think of them
>as the endpoints of a cylinder.  The goal is to rotate that cylinder
>so that the ends of the cylinder are at the pair of points.
>
>Notice that we do NOT have any rotational angles to work with.  Only
>a pair of points in 3space.  Obviously what I'm describing is to transform
>a pair of points in 3space to a set of rotational angles.
>
>Now, if you're thinking "just read the angles off of the cylinder's
>transform", remember that the cylinder has not been rotated yet.  I don't
>have those rotations.  I have a pair of endpoints.
>
>This problem could like be solved with my own custom code, but I wonder if
>Java3d has any implicit tools (Matrix, Vector) which can facilitate this
>conversion from points in 3space to the transform.
>
>-- John
>
>
>On Sun, 30 Sep 2001, Eric Reiss wrote:
>
> > Date: Sun, 30 Sep 2001 22:30:28 -0400
> > From: Eric Reiss <[EMAIL PROTECTED]>
> > Reply-To: Discussion list for Java 3D API <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: Re: [JAVA3D] How to rotate objects?
> >
> > I think we still need to clear some things up here.  First you said you
> > wanted to rotate an object to a known rotation value, so I showed you how
> > to use the setRotation method to set the object to an exact orientation
> > about the XYZ axises.  In this case, we just did a SET, we didn't care how
> > the object was originally orientated (rotation wise).
> >
> > If you want to rotate an object by an additional amount then all you have
> > to do is to do a GET on the rotation and put that into a Matrix3d instead
> > of creating a Matrix3d and setting it to the identity matrix, you set it to
> > the existing rotation matrix of the object.  Next you create a new rotation
> > matrix3d and do the rotX, rotY and rotZ with the angles on this
> > matrix.  Finally you multiple the two matrices together and then to the
> > setRotation method with this resulting matrix.
> >
> > This is how you would add a rotation to an object's current rotation.
> >
> >
> >
> >
> >
> > At 09:41 PM 09/30/2001 -0400, you wrote:
> > >Well, the rotations that we had discussed before assume that you know the
> > >component angles for each coordinate.  In some cases, I know the endpoints
> > >of a cylinder.  Don't know the angle that this cylinder makes with any
> > >particular axis.  Just know the endpoints.  So how would I transform a
> > >pair of endpoints into angles that allow me to rotate that cylinder?
> > >
> > >-- John
> > >
> > >On Sun, 30 Sep 2001, Eric Reiss wrote:
> > >
> > > > Date: Sun, 30 Sep 2001 20:42:22 -0400
> > > > From: Eric Reiss <[EMAIL PROTECTED]>
> > > > Reply-To: Discussion list for Java 3D API
> <[EMAIL PROTECTED]>
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: [JAVA3D] How to rotate objects?
> > > >
> > > > I think you need to explain this a little more.  Getting a rotation
> from
> > > > points would require a little more explanation.
> > > >
> > > > At 08:37 PM 09/30/2001 -0400, you wrote:
> > > > >Thanks...
> > > > >
> > > > >I tried something similar to this but I instantiated the
> Transform3d with
> > > > >the rotation matrix as one of the constructor's parameters.  The API
> > > > >reference says you can do this but it didn't work.  I'll try your
> > > > >suggestion (using setRotation) and see if that does the trick.
> > > > >
> > > > >Oh, one more question... is there an easy way to create a rotation
> matrix
> > > > >based on a pair of Points or Vectors describing two endpoints?  I
> don't
> > > > >necessarily know the angle for rotations.  Sometimes I start with the
> > > > >endpoints.
> > > > >
> > > > >-- 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".
> >
> > ***********************************************************************
> > Eric N. Reiss
> > MEMS Manager
> > Swanson Center for Product Innovation
> > Department of Mechanical Engineering
> > School of Engineering  - University of Pittsburgh
> >
> > 3700 O'Hara Street
> > 647 Benedum Hall
> > Pittsburgh, Pennsylvania 15261
> > Phone: 412-624-9696
> > FAX: 412-624-7701
> > Email: [EMAIL PROTECTED]
> > http://www.sigda.org/Eric/
> > ***********************************************************************
> >
> > ===========================================================================
> > 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".
> >
>
>--
>_____________________________________________________
>
>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".

***********************************************************************
Eric N. Reiss
MEMS Manager
Swanson Center for Product Innovation
Department of Mechanical Engineering
School of Engineering  - University of Pittsburgh

3700 O'Hara Street
647 Benedum Hall
Pittsburgh, Pennsylvania 15261
Phone: 412-624-9696
FAX: 412-624-7701
Email: [EMAIL PROTECTED]
http://www.sigda.org/Eric/
***********************************************************************

===========================================================================
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".

Reply via email to