Computer Graphics View Transformation
Computer Graphics View Transformation
VIEWING
INTRODUCTION
3D Camera Transformation
In graphics we usually use a camera analogy, i.e., the viewer, located at the View
Reference Point (VRP), observes the scene through a camera and can move around the
scene. This is accomplished by defining a viewing coordinate system (VCS) (left handed),
which has the position and orientation of the camera. Then we align the VCS with the
world coordinate system (WCS), creating a viewing transformation matrix. This matrix is
then applied to all the objects in the scene, which moves them into the proper position as
seen from the VRP. This is assumed the world coordinate system is right handed.
When we define an image in some world coordinate system, to display that image we
must map the image to the physical output device. This is a two stage process. For 3
dimensional images we must first determine the 3D camera viewpoint, called the View
Reference Point (VRP) and orientation. Then we project from 3D to 2D, since our display
device is 2 dimensional. Next, we must map the 2D representation to the physical device.
3D Viewing Projections
There are two general methods of 3D viewing projections: Parallel and Perspective
1
Viewing
Projection rays (projectors) emanate from a Center of Projection (COP) and intersect
Projection Plane (PP).
The COP for parallel projectors is at infinity. The length of a line on the projection
plane is the same as the "true Length".
2
Viewing
Orthographic projections that show more than 1 side of an object are called
axonometric orthographic projections.
The most common axonometric projection is an isometric projection where the
projection plane intersects each coordinate axis in the model coordinate system at an
equal distance.
Isometric Projection
The projection plane intersects the x, y, z axes at equal distances and the projection
plane Normal makes an equal angle with the three axes.
To form an orthographic projection xp = x, yp= y , zp = 0. To form different types
e.g., Isometric, just manipulate object with 3D transformations.
3
Viewing
Oblique Projection
The projectors are not perpendicular to the projection plane but are parallel from the
object to the projection plane The projectors are defined by two angles A and d where:
A = angle of line (x,y,xp,yp) with projection plane,
d = angle of line (x, y, xp, yp) with x axis in projection plane
L = Length of Line (x,y,xp,yp).
Now if A = 90° (projection line is perpendicular to PP) then tan A = infinity => L1 =
0, so have an orthographic projection.
1) A = 45° , tanA = 1 => L1 = 1 This is a Cavalier projection such that all lines
perpendicular to the projection plane is projected with no change in length.
2) A= 63.40°, tanA = 2, L1 = 1 / 2
Lines which are perpendicular to the projection plane are projected at 1 / 2
length . This is a Cabinet projection.
4
Viewing
So the distance of a line from the projection plane determines its size on the
projection plane, i.e. the farther the line is from the projection plane, the smaller its
image on the projection plane.
In the two images above, the projections of L1 = L2 but the actual length of L1 <> L2.
Perspective projection is more realistic since distant objects appear smaller.
Vanishing Points
Any set of parallel lines that are not parallel to the projection plane will converge to a
vanishing point.
If the set of lines is parallel to one of the three principal axis then it is called a
principal vanishing point.
5
Viewing
In this image the X and Y lines are parallel to the Z axis. Since the projection plane is
normal to the Z axis there is only one principal vanishing point.
Lines parallel to either X or Y axis are parallel to projection plane and have no
vanishing point. So it is a one-point projection.
6
Viewing
In this image the lines are not parallel to the z axis. Since the projection plane
is normal to the z axis there is only one principal vanishing point. Lines
parallel to either x or y axis are parallel to projection plane and have no
vanishing point. So it is a one-point projection.
glMatrixMode (GL_MODELVIEW);
GL_MODELVIEW
- used to store and combine the geometric transformation.
- It is also used to combine the geometric transformations with the
transformation to a viewing-coordinate system. Hence modelview mode is
specified with the statement
glMatrixMode (GL_MODELVIEW);
which designate a 4 by 4 modelview matrix as the current matrix.
7
Viewing
GlMatrixMode
A routine used to set the projection mode, designates the matrix that is
to be used for the projection transformation.
Transformation determines how a scene is to be projected onto the
screen.
gluLookAt
Viewing parameters are specified with the following GLU function, which is in the
OpenGL utility library because it invokes the translation and rotation routines in the
basic OpenGL library.
gluLookAt (x0, y0, z0, xref, yref, zref, vx, vy, vz);
e.g.
gluLookAt (100.0, 50.0, 50.0, 50.0, 50.0, 0.0, 0.0, 1.0, 0.0);
The positive zview axis for the viewing frame is in the direction N = P0 – Pref
Unit axis vectors for the viewing reference frame are calculated as in the figure below
View Plane
8
Viewing
Since the viewing direction is a long the –zview axis, the reference position Pref is
also referred to as the “look-at-point”.
This is usually taken to be some position in the center of the scene that we can use as
a reference for specifying the projection parameters.
And we can think of the reference position as the point at which we want to aim that
is located at the viewing origin.
The up orientation for the camera is designated with vector V, which is adjusted to a
direction perpendicular to N.
Viewing parameters specified with the
gluLookAt function
NOTE: If we do not invoke values, the viewing reference frame is the same as the
world frame, with the viewing direction along the negative zworld axis.
Projection matrices are stored in the OpenGL projection mode. So, to set up a
projection-transformation matrix, we must first invoke that mode with the statement:
glMatrixMode (GL_PROJECTION);
Then, when we issue any transformation command (the gluLookAt function), the
resulting matrix will be concatenated with the current projection matrix.
Orthogonal-projection parameters are chosen with the function
GlOrtho is used to select the clipping-window coordinates and the distances to the
near and far clipping planes from the viewing origin.
There is no option in OpenGL for the placement of the view plane. The near clipping
plane is always also the view plane, and therefore the clipping window is always on
the near plane of the view plane.
Function glOrtho generates a parallel projection that is perpendicular to the view
plane (the near clipping plane).
Thus, this function generates a finite orthogonal projection view volume for the
specified clipping planes and clipping window.
In OpenGL, the near and far plane are not optional; they must always be specified for
any projection transformation.
9
Viewing
Parameters dnear and dfar denotes distances in the negative zview direction from the
viewing-coordinate origin.
Example:
If dfar = 55.0, then far clipping plane is at the coordinate position zfar = -55.0
A negative value for either parameter denotes a distance “behind” the viewing
origin, along the positive zview axis.
We can assign any values for the OpenGL orthogonal-projection function are –1 or
+1, which produce a view volume that is a symmetric normalized cube in the right-
handed viewing coordinate system. This default is equivalent to issuing the statement
The default clipping window is thus a symmetric normalized square, and the default
view volume is a symmetric normalized cube with
yview
Top
Far Clipping
Clipping Window
Window
xview
Left
Near Clipping
Right Window
zview
10
Viewing
For a 2-D application, we use the gluOrtho2D function to set up the clipping window
e.g.
gluOrtho2D (xwmin, xwmax, ywmin, ywmax);
We could also use the glOrtho function to specify the clipping window, as long as
parameters dnear and dfar are assigned values that were on opposite sides of the
coordinate origin.
In fact, a call to gluOrtho2D is equivalent to a call to glOrtho
There are two functions for producing a perspective projection view of a scene.
i) One of these functions generates a symmetric frustum view volume about the
viewing direction (the negative zview axis).
ii) The other function can be used for either a symmetric-perspective projection.
For both functions, the projection reference point is the viewing-coordinate origin and
the near clipping plane is the view plane.
A symmetric, perspective-projection, frustum view volume is set up with the GLU
function
11
Viewing
Clipping yview
Window
xview
θ zview
Parameter
Aspect is assigned a value for the aspect ration (width / height) of the clipping
window.
Clipping Window
Height
zview
Θ/2
Zprp - Zvp
12
Viewing
We can use the following function to specify a perspective projection that has either a
symmetric frustum view volume or an oblique frustum view volume.
13