480 likes | 883 Views
CSCE 441 Computer Graphics. Jinxiang Chai. Midterm. Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113 . What you’ve learned in this class?. 2D Graphics Drawing lines, polygons Color 3D Graphics Transformations Hidden surface removals. Scan Line Conversion. How to draw a line?
E N D
CSCE 441 Computer Graphics Jinxiang Chai
Midterm • Time: 10:10pm-11:20pm, 10/20 • Location: HRBB 113
What you’ve learned in this class? • 2D Graphics • Drawing lines, polygons • Color • 3D Graphics • Transformations Hidden surface removals
Scan Line Conversion • How to draw a line? - Digital Differential Analyzer (DDA) - Midpoint algorithm - Understand both algorithms - Strengths and limitations
Scan Conversion of Polygons • How to draw a polygons? - Active edge list - Boundary fill - Flood fill - Understand three algorithms - Limitations and strengths
Clipping Lines • Given a line with end-points (x0, y0), (x1, y1) and clipping window (xmin, ymin), (xmax, ymax), determine if line should be drawn and clipped end-points of line to draw. (xmax,ymax) (x1, y1) (x0, y0) (xmin,ymin)
Line Clipping • How to clip a line? - Simple line clipping algorithm - Cohen--Sutherland - Liang-Barsky
Clipping Polygons • Clipping polygons is more complex than clipping the individual lines • - Input: polygon
Clipping Polygons • Clipping polygons is more complex than clipping the individual lines • - Input: polygon • - Output: original polygon, new polygon, or nothing
Polygon Clipping • How to clip a polygon? - Sutherland-Hodgman Clipping (convex polygons) - Weiler-Atherton Algorithm (general polygons)
2D/3D Transformation • Various transform matrices - 2D/3D rotation - 2D/3D translation - 2D/3D scaling - 2D affine transform
Arbitrary Rotation Center (px,py) To rotate about an arbitrary point P (px,py) by q:
Arbitrary Rotation Center (px,py) • To rotate about an arbitrary point P (px,py) by q: • Translate the object so that P will coincide with the origin: T(-px, -py)
Arbitrary Rotation Center (px,py) • To rotate about an arbitrary point P (px,py) by q: • Translate the object so that P will coincide with the origin: T(-px, -py) • Rotate the object: R(q)
Arbitrary Rotation Center (px,py) • To rotate about an arbitrary point P (px,py) by q: • Translate the object so that P will coincide with the origin: T(-px, -py) • Rotate the object: R(q) • Translate the object back: T(px,py)
x’ 1 0 px cos(q) -sin(q) 0 1 0 -px x y’ = 0 1 py sin(q) cos(q) 0 0 1 -py y 1 0 0 1 0 0 1 0 0 1 1 Arbitrary Rotation Center • Translate the object so that P will coincide with the origin: T(-px, -py) • Rotate the object: R(q) • Translate the object back: T(px,py) • Put in matrix form: T(px,py) R(q) T(-px, -py) * P
Scaling Revisit • What if I want to scale about an arbitrary pivot point? • The standard scaling matrix will only anchor at (0,0) Sx 0 0 0 Sy 0 0 0 1
2D/3D Coordinate Transformation • Various transform matrix - 2D/3D rotation - 2D/3D translation - 2D/3D scaling - 2D affine transform • How to do 2D/3D matrix composition
2D Coordinate Transformation p Transform object description from to 21
2D Coordinate Transformation 0 1 p 0 1 2D translation 22
2D Coordinate Transformation p 2D translation&rotation 23
2D Coordinate Transformation p 2D translation & scaling 24
Hierarchical Modeling: Lamp How to do opengl implementation? What’s the current coordinate A ? 25
A More Complex Example: Human Figure How to do opengl implementation?
3D->2D Geometry Pipeline Rotate and translate the camera Object space World space View space Focal length Aspect ratio & resolution Normalized project space Image space 27
3D Geometry Pipeline Model space (Object space) Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 28
3D Geometry Pipeline World space (Object space) Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 29
3D Geometry Pipeline Eye space (View space) Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 30
3D Coordinate Trans. Transform object description from camera to world 32
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) 33
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) How to determine ? Mapping from world to eye coordinates
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) Mapping from world to eye coordinates
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) Mapping from world to eye coordinates
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) H&B equation (7-1) Mapping from world to eye coordinates
3D Geometry Pipeline Normalized projection space Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 38
3D->2D By similar triangles, we can compute how much the x and y coordinates are scaled Consider the projection of a point on the camera plane 39
The Perspective Matrix After the division by w, we have Now we can rewrite the perspective projection equation as matrix-vector multiplications 40
Projections • Parallel projection - definition - properties • Perspective projection - definition - homogeneous coordinates - vanishing point - properties
3D Geometry Pipeline Image space, window space, raster space, screen space, device space Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 42
3D Rendering pipeline Modeling transformation Transform into 3D world system Illuminate according to lighting and reflectance lighting Transform into 3D camera coordinate system Viewing transformation Transform into 2D camera system Project transformation Clip primitives outside camera’s view Clipping Draw pixels (includes texturing, hidden surface, etc.) Scan conversion Image
Hidden Surface Removals • Backface Culling • Painter’s algorithm • BSP • Z-buffer • Scan line • Ray casting
For Example, BSP Tree 6 7-2 5-2 3 7-1 5-1 1 2 4 1 b 3 f b 7-1 7-2 f b b 4 6 2 b f Traversal order? 1->6->(5-2)->(7-2)->3->4->(5-1)->(7-1)->2 5-1 5-2
Color • Understanding chromaticity diagram and its concept • Understanding various color models: - RGB - CMY/CMYK - YUV/YIQ - HSV - XYZ, etc.
Chromaticity Diagram • How to obtain chromaticity diagram? • Where are spectral colors and non-spectral colors located? • How to determine purity/saturation and dominant wave length/hues for a given color? • How to identify complementary colors? • How to compare color gamuts for different primaries? • Why three primary colors are not sufficient to represent all colors? Image taken from http://fourier.eng.hmc.edu/e180/handouts/color1/node27.html
What you’ve learned in this class? • 2D Graphics • Drawing lines, polygons Color • 3D Graphics • Transformations