Brian Schott wrote:
> There seems to be a flaw still because I always get
> 0 0 0 = center . For example, when I supply the following
> inputs to gluLookAt
>
> eye =. 0 0 6
> center =. 0 1 0
> up =. 1 1 0
>
> the corresponding M produced (I call it Y) is
> Y =. |:4 4$0.707107 0.707107 0 0 _0.707107 0.707107 0 0 0 0 1 0 0 0 _6
1
I think the issue here is that 0 0 0 and 0 1 0 are on
the same line -- going into the screen, once the axes
derived from eye/center/up are made orthogonal.
If you don't want center to be 0 0 0, you can change the
scalar value "scale" in tAkool. For example:
tAkool=:3 :0
assert 0 0 0 1-:3{y
eye=. -3 7 11{,y %. y*-.(i.4 4)e.3 7 11
scale=.2*+/&.:*: eye
's up nf'=. 3 3 {.y%.(=/~i.4)+_4{.&>4{.-eye
center=. eye-scale*nf
eye,center,up
)
I could have made a mistake here, but if so I've got a
blind spot that's keeping me from seeing it -- if you
think this is wrong, perhaps you could construct an
example which shows unambiguously that it's wrong?
> Btw, I don't really understand why the more
> complicated version of eye is required, but I have a case
> for which the complicated version gives a better answer.
I'm finding the inverse of:
M+/ .*(=/~i.4)+_4{.&>4{.-eye
The issue is that the translation elements are, in
essence, being transformed by the 3x3 rotation matrix:
]M=: (1+i.3 3),_4{.1
1 2 3 0
4 5 6 0
7 8 9 0
0 0 0 1
M+/ .*(=/~i.4)+_4{.&>4{.-100 10 1
1 2 3 _123
4 5 6 _456
7 8 9 _789
0 0 0 1
So I need to divide by that transform before I can
retrieve the original values:
Y=:((?3 3$0),_4{.1)+/ .*(=/~i.4)+_4{.&>4{.-83 89 97
-3 7 11 {,Y %. Y*-.(i.4 4)e.3 7 11
83 89 97
Note also:
-.(i.4 4)e.3 7 11
1 1 1 0
1 1 1 0
1 1 1 0
1 1 1 1
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm