Geometric Objects Computer Graphics Lab. Sun-Jeong Kim
Korea University Computer Graphics -2- Points Single Coordinate Position Set the bit value(color code) corresponding to a specified screen position within the frame buffer x y setPixel (x, y)
Korea University Computer Graphics -3- Lines Intermediate Positions between Two Endpoints DDA, Bresenham’s line algorithms Jaggies = Aliasing
Korea University Computer Graphics -4- DDA Algorithm Digital Differential Analyzer Slope >= 1 Unit x interval = 1 0 < Slope < 1 Unit y interval = 1 Slope <= -1 Unit x interval = -1 -1 < Slope < 0 Unit y interval = -1 x1 y1 x2 y2 x1 y1 x2 y2 x1 y1 x2 y2 x1 y1 x2 y2
Korea University Computer Graphics -5- Bresenham ’ s Line Algorithm Midpoint Line Algorithm Decision variable NE M Q d > 0 : choose NE : d new = d old +a d <= 0 : choose E : d new = d old +a+b P(x p, y p )E
Korea University Computer Graphics -6- Bresenham ’ s Algorithm(cont.) Initial Value of d Update d
Korea University Computer Graphics -7- Polygons Filling Polygons Scan-line fill algorithm Inside-Outside tests Boundary fill algorithm
Korea University Computer Graphics -8- Scan-Line Polygon Fill Topological Difference between 2 Scan lines y : intersection edges are opposite sides y’ : intersection edges are same side y y’
Korea University Computer Graphics -9- Scan-Line Polygon Fill (cont.) Edge Sorted Table C C’ B D E A 0 1 yAyA yDyD yCyC Scan-Line Number yEyE xAxA 1/m AE yByB xAxA 1/m AB y C’ xDxD 1/m DC yEyE xDxD 1/m DE yByB xCxC 1/m CB
Korea University Computer Graphics -10- Inside-Outside Tests Self-Intersections Odd-Even rule Nonzero winding number rule exterior interior
Korea University Computer Graphics -11- Boundary-Fill Algorithm Proceed to Neighboring Pixels 4-Connected 8-Connected
Korea University Computer Graphics -12- Antialiasing Aliasing Undersampling: Low-frequency sampling Nyquist sampling frequency: Nyquist sampling interval:
Korea University Computer Graphics -13- Antialiasing (cont.) Supersampling (Postfiltering) Pixel-weighting masks Area Sampling (Prefiltering) Pixel Phasing Shift the display location of pixel areas Micropositioning the electron beam in relation to object geometry
Korea University Computer Graphics -14- Supersampling Subpixels Increase resolution (10, 20): Maximum Intensity (11, 21): Next Highest Intensity (11, 20): Lowest Intensity
Korea University Computer Graphics -15- Pixel-Weighting Masks Give More Weight to Supixels Near the Center of a Pixel Area
Korea University Computer Graphics -16- Area Sampling Set Each Pixel Intensity Proportional to the Area of Overlap of Pixel 2 Adjacent vertical (or horizontal) screen grid lines trapezoid (10, 20): 90% (10, 21): 15%
Korea University Computer Graphics -17- Filtering Techniques Filter Functions (Weighting Surface) Box FilterCone FilterGaussian Filter
Mathematics for CG
Korea University Computer Graphics -19- Coordinate Reference Frames 2D Cartesian Reference Frames x y x y
Korea University Computer Graphics D Polar Coordinate Reference Frame
Korea University Computer Graphics D Cartesian Reference Frame Right-Handed v.s. Left-Handed Right-handedLeft-handed
Korea University Computer Graphics D Curvilinear Coordinate Systems General Curvilinear Reference Frame Orthogonal coordinate system Each coordinate surfaces intersects at right angles
Korea University Computer Graphics -23- Cylindrical-Coordinate : radius of vertical cylinder : vertical plane containing z-axis : horizontal plane parallel to xy-plane constant Transform to Cartesian coordinator x axis y axis z axis
Korea University Computer Graphics -24- Spherical-Coordinate : radius of sphere : vertical plane containing z-axis : cone with the apex at the origin constant Transform to Cartesian coordinator x axis y axis z axis
Korea University Computer Graphics -25- Solid Angle 3D Angle Defined on a Sphere Steradian Steradian : Total solid angle : steradian
Korea University Computer Graphics -26- Points & Vectors Point Position in some reference frame Distance from the origin depends on the reference frame P Frame B Frame A x y
Korea University Computer Graphics -27- Points & Vectors (cont.) Vector Difference between two point positions Properties : Magnitude & direction Same properties within a single coordinate system Magnitude is independent from coordinate frames Magnitude : Direction :
Korea University Computer Graphics D Vector Magnitude Directional angle
Korea University Computer Graphics -29- Vector Addition & Scalar Multiplication Addition Scalar multiplication
Korea University Computer Graphics -30- Vector Multiplication Scalar Product(Inner Product) Commutative : Distributive : Orthogonal :
Korea University Computer Graphics -31- Vector Multiplication (cont.) Vector Product(Cross Product) Noncommutative : Nonassociative : Distributive : Right-handed rule!