# OpenGL Understanding gluLookAt

This topic is 4501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I m trying to understand the inner working of gluLookAt. I found nice formulae here So i gave them a try with these parameters: Eye x=0.00000000 y=2.0000000 z=3.0000000 Center x=0.00000000 y=0.00000000 z=0.00000000 Up x=0.00000000 y=1.0000000 z=0.00000000 I obtained: 0.83205032 0.00000000 0.00000000 0.00000000 0.00000000 0.69230777 0.55470020 0.00000000 0.00000000 -0.46153846 0.83205032 0.00000000 0.00000000 1.4901161e-007 -3.6055512 1.0000000 The i compared this result with the matrix computed by gluLookAt, which is: 1.0000000 0.00000000 0.00000000 0.00000000 0.00000000 0.83205032 0.55470020 0.00000000 0.00000000 -0.55470020 0.83205032 0.00000000 0.00000000 0.00000000 -3.6055512 1.0000000 huh?! I don't understand (particulary the first 1.00000). Are the formulae wrong? What are the right ones? Perhaps my code is wrong but i can't find my mistakes.

##### Share on other sites
When I look at the cited page, I miss some white space and (more critical) some division ops. Especially here:
f=F||F|| must be f=F/||F||
UP'=UP||UP|| must be UP'=UP/||UP||

The matrix gluLookAt returns is a valid combination of a rotation and a translation, while the matrix your code has produced is not. That hints to an error in your code.

Btw: Please notice that you've written down the transpose of the matrices!

##### Share on other sites
Quote:
 Original post by kratolpI obtained:0.83205032 0.00000000 0.00000000 0.00000000 0.00000000 0.69230777 0.55470020 0.00000000 0.00000000 -0.46153846 0.83205032 0.00000000 0.00000000 1.4901161e-007 -3.6055512 1.0000000 The i compared this result with the matrix computed by gluLookAt, which is:1.0000000 0.00000000 0.00000000 0.000000000.00000000 0.83205032 0.55470020 0.000000000.00000000 -0.55470020 0.83205032 0.000000000.00000000 0.00000000 -3.6055512 1.0000000

the difference i think is due to renormalization of the vectors before plugging them into the matrix , and the 1.4901161e-007 seems to be a floating point error (you can or must round it to 0)

hope this help

##### Share on other sites
Thanks to you 2, that was simply a normalization problem.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
18

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632998
• Total Posts
3009805
• ### Who's Online (See full list)

There are no registered users currently online

×