# What is the definition of gluLookAt?

• 05-14-2013, 05:57 AM
wangyubuct
What is the definition of gluLookAt?
The description of the gluLookAt is as follows:
Let
F=centerX-eyeXcenterY-eyeYcenterZ-eyeZ
Let UP be the vector upXupYupZ.
Then normalize as follows:
f=FF
UP″=UPUP
Finally, let s=f×UP″, and u=s×f.
M is then constructed as follows:
M=s⁡0s⁡1s⁡20u⁡0u⁡1u⁡20-f⁡0-f⁡1-f⁡200001 //??????
gluLookAt is equivalent to
glMultMatrixf(M);
glTranslated(-eyex, -eyey, -eyez);

Can you explain the description above?Especially the define of M,the line with ????.
Thank you very much.
• 05-14-2013, 06:09 PM
tonyo_au
http://www.songho.ca/opengl/gl_transform.html

gluLookAt is just a shorthand to create the view model matrix
• 05-15-2013, 04:37 AM
wangyubuct
Thank you for your help,but I have to use gluLookAt in my program.Can you explain the function?
• 05-15-2013, 06:03 AM
Alfonse Reinheart
He just linked you to a very detailed explanation of how transforms work and what it does.

And no, you don't "have to use gluLookAt".
• 05-15-2013, 06:52 AM
thokra
It would be interesting to know what exactly the OP doesn't get about the function. Any specific questions or are you just not understanding anything at all?
• 05-15-2013, 07:48 AM
Aleksandar
I hope a concrete implementation (from MESA3D) would help
Code C:

```gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz) { float forward[3], side[3], up[3]; GLfloat m[4][4];   forward[0] = centerx - eyex; forward[1] = centery - eyey; forward[2] = centerz - eyez;   up[0] = upx; up[1] = upy; up[2] = upz;   normalize(forward);   /* Side = forward x up */ cross(forward, up, side); normalize(side);   /* Recompute up as: up = side x forward */ cross(side, forward, up);   __gluMakeIdentityf(&m[0][0]); m[0][0] = side[0]; m[1][0] = side[1]; m[2][0] = side[2];   m[0][1] = up[0]; m[1][1] = up[1]; m[2][1] = up[2];   m[0][2] = -forward[0]; m[1][2] = -forward[1]; m[2][2] = -forward[2];   glMultMatrixf(&m[0][0]); glTranslated(-eyex, -eyey, -eyez); }```
• 05-15-2013, 07:52 AM
thokra
The thing is, Alfonse is right in saying you don't need to use gluLookAt, because if you get the math behind it, you can write up a function yourself. I suspect the OP doesn't have a sufficient mathematical basis.
• 05-15-2013, 10:06 PM
wangyubuct
This is exactly what I need!!!Thank you so much!
鄙视狗眼看人低。