Jump to content
  • Advertisement
Sign in to follow this  
kratolp

OpenGL Understanding gluLookAt

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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||
Perhaps you have already noticed that, else please correct your code.

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 this post


Link to post
Share on other sites
Quote:
Original post by kratolp

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




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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!