School of Computer Science Computer Graphics (fall,2010) School of Computer Science University of Seoul Minho Kim
Chapter 3 Additional Drawing Tools
What to Learn Orthographic projection Viewport Homogeneous coordinate systems Matrix stack (Clipping) Representations of curves
sample03.c To change the (orthographic 2D) camera setting dynamically – translation & zooming How can we rotate the camera? What types of cameras are supported? What is the default camera setting? What does the projection matrix do? How can we make the image flipped vertically/horizontally? How can we achieve the same effect using glMultMatrix?
Matrix Stacks The top element denotes current matrix state Four stacks: modelview, projection, texture, and color Different (minimum) stack depth for each Stored in column-major format Operations glLoadIdentity, glLoadMatrix, glPushMatrix, glPopMatrix, glMultMatrix, etc. Can handle hierarchical transformation (modelview) – How?
Homogeneous Coordinate System Represents a 3D vectors/points as a 4-tuple: (x,y,z,w) Corresponds to the vectors/points in the Cartesian coordinate system as (x,y,z,w)=(x/w,y/w,z/w) w=0 for vectors and w≠0 for points Can represent a translation as a matrix. Can represent a perspective projection. More in Chapter 4
Clipping How to (efficiently) clip a line segment against an axis-aligned rectangle? → “Cohen-Sutherland clipper”
Representations of Curves Implicit form “Set of points (x,y) satisfying the equation f(x,y)=0” Ex) x2+y2-r2=0 Parametric form “Trace of points (x(t),y(t)) as t changes” Ex) x(t)=r cos(t), y(t)=r sin(t) Pros and cons? How can we convert one to another? How can we plot them? More in Chapter 4