Let X,Y,Z be your local coordinate frame (LF) with origin at 0,0,0 and Z=XcrossY.
Let X',Y',Z', L' be a coordinate frame (CF) expressed in LF where L'
is the location of the origin of CF in LF, X',Y',Z' are the axis' of CF expressed
as orthogonal unit vectors in LF.
Let P be a point expressed in LF, and M be a transform that takes LF
into CF so that P' is the transformed point expressed in LF.  (draw a picture)
 
                                                         | P'x |  = | X'x  Y'x  Z'x  L'x |  | Px |
So P' = MP = [TR]P = [X' Y' Z' L']P  =   | P'y |  = | X'y  Y'y  Z'y  L'y |  | Py |
                                                         | P'z |  = | X'z  Y'z  Z'z  L'z |  | Pz |
                                                         |  1   |  = | 0     0    0     1  |  |  1  |
where all vectors are column vectors, T is translate, R is rotate.
 
FOR EXAMPLE, if P = [ 1  0  0  1] then P' = L' + X'    cool eh?  X maps to X'
 
But you want to transform P' points like start and end to LF so you want the
inverse of M.  P = [Minv]P'  = [Rinv][Tinv]P'
 
The inverse of a rotation matrix is its transpose and the inverse of a translation
is its negation so 
 
             | X'x  X'y   X'z  0  |   |  1    0    0   -L'x |      | X'x   X'y   X'z   -X'dotL'  |
Minv =   | Y'x  Y'y  Y'z  0  |   |  0    1    0   -L'y |  =  | Y'x  Y'y   Y'z  -Y'dotL'  |  
             | Z'x  Z'y  Z'z   0  |   |  0    0    1   -L'z |      | Z'x   Z'y   Z'z   -Z'dotL'  |  
             |  0    0    0     1  |   |  0    0    0     1  |      |  0     0     0        1       |  
 
Your job is to come up with X' Y' Z' and L',   L' is just start,  X' might be
(end - start) normalized.  Take any other vector V from start and
perhaps Z'=X'cross V normalized, and Y'=Z'crossX'.
 
Given more time we could make this even more complicated and confusing but
perhaps we already have too much time on our hands.
 
Mike 
 
 
----- Original Message -----
From: "Stein-Arne Sivertsen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 19, 2002 2:33 AM
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".
>

Reply via email to