xenocara/doc/gl-docs/GLU/lookat.3gl

102 lines
2.3 KiB
Plaintext
Raw Normal View History

2006-11-29 10:01:51 -07:00
'\" e
'\"! eqn | mmdoc
'\"macro stdmacro
.ds Vn Version 1.2
.ds Dt 6 March 1997
.ds Re Release 1.2.0
.ds Dp May 02 11:53
.ds Dm 37 lookat.gl
.ds Xs 1014 4 lookat.gl
.TH GLULOOKAT 3G
.SH NAME
.B "gluLookAt
\- define a viewing transformation
.SH C SPECIFICATION
void \f3gluLookAt\fP(
GLdouble \fIeyeX\fP,
.nf
.ta \w'\f3void \fPgluLookAt( 'u
GLdouble \fIeyeY\fP,
GLdouble \fIeyeZ\fP,
GLdouble \fIcenterX\fP,
GLdouble \fIcenterY\fP,
GLdouble \fIcenterZ\fP,
GLdouble \fIupX\fP,
GLdouble \fIupY\fP,
GLdouble \fIupZ\fP )
.fi
.EQ
delim $$
.EN
.SH PARAMETERS
.TP \w'\f2eyeX\fP\ \f2eyeY\fP\ \f2eyeZ\fP\ \ 'u
\f2eyeX\fP, \f2eyeY\fP, \f2eyeZ\fP
Specifies the position of the eye point.
.TP
\f2centerX\fP, \f2centerY\fP, \f2centerZ\fP
Specifies the position of the reference point.
.TP
\f2upX\fP, \f2upY\fP, \f2upZ\fP
Specifies the direction of the \f2up\fP vector.
.SH DESCRIPTION
\%\f3gluLookAt\fP creates a viewing matrix derived from an eye point, a reference
point indicating the center of the scene, and an \f2UP\fP vector.
.P
The matrix
maps the reference point to the negative \f2z\fP axis and the
eye point to the origin.
When a typical projection matrix is used,
the center of the scene therefore maps to the center of the viewport.
Similarly, the direction described by the \f2UP\fP
vector projected onto the viewing plane is mapped to the positive \f2y\fP
axis so that it points upward in the viewport.
The \f2UP\fP vector must not be parallel to the line of sight from the
eye point to the reference point.
.P
Let
.sp
.EQ
F ~=~ left ( down 20 { ~ matrix {
ccol {"centerX" above "centerY" above "centerZ"}
ccol { ~-~ above ~-~ above ~-~}
ccol {"eyeX" above "eyeY" above "eyeZ"}
} } ~~ right )
.EN
.sp
Let \f2UP\fP be the vector $("upX", "upY", "upZ")$.
.P
Then normalize as follows:
.EQ
f ~=~ F over {|| F ||}
.EN
.P
.EQ
UP sup prime ~=~ UP over {|| UP ||}
.EN
.sp
.P
Finally, let $s ~=~ f ~times~ UP sup prime$, and $u ~=~ s ~times~ f$.
.P
.sp
M is then constructed as follows:
.EQ
M ~=~ left ( matrix {
ccol { ~s[0] above ~u[0] above -f[0] above 0 }
ccol { ~s[1] above ~u[1] above -f[1] above 0 }
ccol { ~s[2] above ~u[2] above -f[2] above 0 }
ccol { 0 above 0 above 0 above 1 }
} ~~right )
.EN
.P
and \%\f3gluLookAt\fP is equivalent to
.Ex
glMultMatrixf(M);
glTranslated (-eyex, -eyey, -eyez);
.Ee
.SH SEE ALSO
\f3glFrustum(3G)\fP, \%\f3gluPerspective(3G)\fP