Brian Schott wrote:
>         I think you have given the transformation from B to
> A, but I need A to B. That is, if M and v are inputs to the
> function, I need outputs eye, center, up, if that is
> possible.
 
Ok.  Hmm...
 
First off, glTranslated -eye is equivalent to
glMultMatrix (=/~i.4)+_4{.&>4{.-eye
 
So I think what you really want is: given a projection (technically,
or modelview -- but that's probably a bad choice)  matrix, find the
corresponding gluLookAt parameters.  To actually use those
gluLookAt parameters you'd typically want the corresponding matrix
to be the identity, but that's easy enough.
 
Let's say that our parameters for gluLookAt are three 3vectors:
eye, center and up.  Conceptually, gluLookAt converts these
to an x, y and z axis (M) and an origin (eye) and builds the
corresponding 4matrix.  But you can build other 4matrices which
cannot be built by gluLookAt.  Also, note that the precise location
of center and up do not matter -- all that matters is their direction
with respect to eye.  And, for that matter, even their precise 
direction isn't the issue -- the axes  generated by gluLookAt have
to be orthogonal to each other, so if the vector from eye to
center is not orthogonal to the vector from eye to up we will
not be able to recover that information.
 
Anyways, let's say that the multiplication matrix we want to arrive at
through gluLookAt is y:

 assert 0 0 0 1-:3{y
 eye=: -4 8 12 {,y
 scale=:+/&.:*: eye
 's up nf'=: 3 3 {.y
 center=: eye-scale*nf
 
In other words, given:
 
tAkool=:3 :0
 assert 0 0 0 1-:3{y
 eye=. -4 8 12 {,y
 scale=.+/&.:*: eye
 's up nf'=. 3 3 {.y
 center=. eye-scale*nf
 eye,center,up
)
normalize=: ] % +/&.:*: 
X=: (1&|[EMAIL PROTECTED] * _1&|[EMAIL PROTECTED]) - _1&|[EMAIL PROTECTED] * 
1&|[EMAIL PROTECTED] 
  
lookAt=:3 :0 
 y+9#0 
 'eye center up'=. 3 3$y 
 f=.normalize center-eye 
 s=.normalize f X normalize up 
 u=.normalize s X f 
 M=.s,u,(-f),:_4{.1 
 M+/ .*(=/~i.4)+_4{.&>4{.-eye 
) 
 
   (] -: [EMAIL PROTECTED]) tAkool lookAt ?9#0
1
 
 
 
-- 
Raul
 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to