C481 B581 Computer Graphics
Dana Vrajitoru

Introduction to 3D Graphics

3D Graphics Coordinate Systems
Projection

Def. P(x, y, z) -> P'(x', y', z') in the projection plane p.
Usually the projection plane is defined by z'=0.

2 types of projection: parallel, perspective.
Parallel projection: orthographic or oblique.

The parallel projection

Features of the parallel projection:

The perspective projection: from a projection center C representing the viewer's eye.

Features of the perspective projection:

Projection in OpenGL

Camera


3D Transformations

Def. A function F : R3 -> R3 such that Po(xo, yo, zo) -> P(x, y, z).

Homogeneous coordinates: represent each point as a vector with 4 coordinates.
Every transformation can be represented as a 4x4 matrix.
 
P =  x
y
z
1

Translation of vector Tv=(tx, ty, tz)
 

x
y
z
1
=
1
0
0
0
0
1
0
0
0
0
1
0
tx
ty
tz
1
xo
yo
zo
1
In OpenGL:
glTranslatef(xt, yt, zt);
glTranslated(xt, yt, zt);

Scaling of factors Sv=(sx, sy, sz)
 

x
y
z
1
=
sx
0
0
0
0
sy
0
0
0
0
sz
0
0
0
0
1
xo
yo
zo
1
In OpenGL:
glScalef(sx, sy, sz);
glScaled(sx, sy, sz);

Rotation: more complex than in 2D.

Around the 0x axis of angle q :

x
y
z
1
=
1
0
0
0
0
cos q
sin q
0
0
- sin q
cos q
0
0
0
0
1
xo
yo
zo
1

Around the 0y axis of angle q :

x
y
z
1
=
cos q
0
sin q
0
0
1
0
0
- sin q
0
cos q
0
0
0
0
1
xo
yo
zo
1

Around the 0z axis of angle q :

x
y
z
1
=
cos q
sin q
0
0
- sin q
cos q
0
0
0
0
1
0
0
0
0
1
xo
yo
zo
1

Any arbitrary rotation about the origin R can be expressed as a unique product (composition) of a rotation about two of the 3 axes. For example: R = Rx Rz.We can determine the rotation matrix for R by multiplying the rotation matrix for Rx with the rotation matrix for Rz.

In OpenGL: In general, defined by an angle and an axis:
glRotatef(angle, vx, vy, vz);
glRotated(angle, vx, vy, vz);

Example: rotate around Oy, by an angle of 30o:
glRotatef(30.0, 0.0, 1.0, 0.0);

Composing the transformations


Projection as Transformation

Matrix Mode in OpenGL

Matrix Operations