Title: Geometric Transformation
1Geometric Transformation 3-D Viewing
ECS175 Discussion Session 3
- Hiroshi Akiba Jan 30, 2004
2Outline
- Geometric Transformations
- Translation
- Scaling
- Rotations
- Problem1
- 3-D Viewing
- Perspective Viewing
- Problem2
- GLUT Callback functions
3Geometric Transformation
- Affine Transformation
- Preserve parallel lines and finite points.
- Includes Translation, Rotation, Scaling,
Reflection, Shear
43-D Translation
- Translate point P(x,y,z) to P(x,y,z) by
distance d(tx,ty,tz)
P
P
d
53-D Scaling
- Scale point P(x,y,z) to P(x,y,z) by a factor
of s(sx,sy,sz)
P
P
63-D Rotations (x-axis)
- Rotate point P(x,y,z) to P(x,y,z) by
y
z
x
73-D Rotations (y-axis)
- Rotate point P(x,y,z) to P(x,y,z) by
y
z
x
83-D Rotations (z-axis)
- Rotate point P(x,y,z) to P(x,y,z) by
y
z
x
9Transformation Matrices
- Complex transformations are obtained by the
product of these matrices
10Problem1 Rotation About a Fixed Point
- Q Give a 4x4 matrix M for rotating a cube ?
about the axis passing through P(-1,2,1) and
parallel to z axis. Here, P is a center of the
cube.
y
x
z
11Problem1 Rotation About a Fixed Point
- Solution
- M is the matrix to translate P to somewhere in
the z axis such as origin, rotate ?about z axis,
and translate back to P. Let the first
translation matrix T and the rotation matrix R,
then -
- where
-
- the answer is verified by
123-D Viewing
- Viewing(camera) coordinates
- Define position and orientation of a camera
- Object need to be described by this coordinates
?superimpose the viewing coordinates onto the
world coordinates
Yw
Yw
gluLookAt(eye, at, up)
Xv
Yvup
Yv
d
eye
at
Zv
Xv
Zv
Zw
Zw
Xw
Xw
13Perspective Projection
- Projection reference point(center of projection)
Yw
Projection reference point
View Plane
Zw
Xw
14Problem2 Perspective Projection
- Q What are view coordinates of the perspective
projection of the point P(3,3,-5) onto the view
plane z-2. Here, the projection reference point
is at (0,0,1) in the view coordinates.
P
Yw
?
Projection reference point
Zw
Xw
15Problem2 Perspective Projection
- Solution
- Since the point is on the z-2 plane, z
coordinate is 2 - x and y coordinates are found by following graph
- Hence, the answer is (3/2, 3/2, -2)
16GLUT callback functions
- glutDisplayFunc(disp)
- void disp(void)
- glutKeyboardFunc(key)
- void key(unsigned char key, int x, int y)
- glutMouseFunc(mouse)
- void mouse(int button, int state, int x, int y)
- glutReshapeFunc(reshape)
- void reshape(int width, int height)
17Examples
Void mouse(int button, int state, int x, int y)
if(state GLUT_DOWN buttonGLUT_LEFT_BUTTO
N) exit(1) if(state GLUT_DOWN
buttonGLUT_RIGHT_BUTTON)
glutPostRedisplay()
Void key(char key) if(keyq keyQ
key \27) exit(0)
18References
- 1.Hearn baker, Computer Graphics width OpenGL,
2004 - 2.Edward Angel, Interactive Computer Graphics A
Top-Down Approach with OpenGL, 2000 - 3. Edward Angle, OpenGL A PRIMER, 2002
- 4.OpenGL Red Book, http//www.opengl.org/documenta
tion/red_book_1.0/