On Thu, 14 Dec 2006, Miller, Raul D wrote:

+
+ Ok.  Hmm...
+
+ First off, glTranslated -eye is equivalent to
+ glMultMatrix (=/~i.4)+_4{.&>4{.-eye

        Using the phrase '_4{.&>4{. y' where y is of
length<4 to get a 4x4 result is very clever to me.

+
+ 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

        I think this should be eye=: -3 7 11{,y

+  scale=:+/&.:*: eye
+  's up nf'=: 3 3 {.y

        What do s and nf stand for here? I think it does
make sense to use the middle vector in 3 3{.y for up.

+  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

        I cannot understand why you are checking this match?
Is the double application of tAkool lookAt necessary to
first create the valid input and then to test the input?
Such a strategy seems like forcing a match.

+
+
+
+ --
+ Raul
+
+

        Thank you, Raul.

(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to