If you take the cross product of the two vectors (the "beam" vector and the "axis" 
vector), you will get a vector orthogonal to both of them (the order that you take the 
cross product will determine which of the two orthogonal vectors you get -- right-hand 
rule). Use this as your axis of rotation. Then, compute the angle between the two 
vectors (I believe the vecmath package provides a method for this). This will give you 
the degrees radians to rotate around the axis of rotation. You can now create an 
AxisAngle object from these values and use the setRotation(AxisAngle) method of one of 
the Matrix objects (or compute your own matrix components). This Matrix can then be 
used to set a Transform3D.

Note: This will only set the rotational components of the matrix/transform. You will 
have to set the translational components separately, but this shouldn't be difficult.

Sean Sylvis
Engineer, Pharmix Corp. 


> -----Original Message-----
> From: Stein-Arne Sivertsen
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 19, 2002 2:34 AM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D]
> 
> 
> I have a rather simple question which might be a bit 
> off-topic, but i am
> looking for a method that can take a beam/line represented by 
> two points
> [start,end] anywhere in space and produce the Transform3D 
> that coincides
> the line with one of the principal axis (local coordinates, 
> with startpoint
> in origo). I guess it is something that is done often, so 
> maybe someone has
> this for me to reuse.
> 
> I will use the inverse transform to replace a line with some 
> more complex
> geometry (which i have generated along an axis ) this means 
> the orientation
> of the line to be replaced has some significance. It is therefore an
> advantage if the method can handle either a third point for 
> the line or
> maybe an up-vector or something similar to determine this.
> 
> 
> 
> Regards,
> 
> ==============================================================
> =============
> 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".

Reply via email to