330 likes | 552 Vues
Geometric Objects. 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim. Points. Single Coordinate Position Set the bit value(color code) corresponding to a specified screen position within the frame buffer. y. setPixel ( x , y ). x. Lines. Intermediate Positions between Two Endpoints
E N D
Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim
Points • Single Coordinate Position • Set the bit value(color code) corresponding to a specified screen position within the frame buffer y setPixel (x, y) x
Lines • Intermediate Positions between Two Endpoints • DDA, Bresenham’s line algorithms Jaggies = Aliasing
y2 y2 y2 y2 y1 y1 y1 y1 x1 x1 x1 x1 x2 x2 x2 x2 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
d > 0 : choose NE : dnew= dold+a • d <= 0 : choose E : dnew= dold+a+b Bresenham’s Line Algorithm • Midpoint Line Algorithm • Decision variable NE Q M P(xp, yp) E
Bresenham’s Algorithm(cont.) • Initial Value of d • Update d
Polygons • Filling Polygons • Scan-line fill algorithm • Inside-Outside tests • Boundary fill algorithm
Scan-Line Polygon Fill • Topological Difference between 2 Scan lines • y : intersection edges are opposite sides • y’ : intersection edges are same side y y’
Scan-Line Polygon Fill (cont.) • Edge Sorted Table B yC yB xC 1/mCB C C’ E yD yC’ xD 1/mDC yE xD 1/mDE D yA yE xA 1/mAE yB xA 1/mAB A 1 Scan-Line Number 0
Inside-Outside Tests • Self-Intersections • Odd-Even rule • Nonzero winding number rule exterior interior
Boundary-Fill Algorithm • Proceed to Neighboring Pixels • 4-Connected • 8-Connected
Antialiasing • Aliasing • Undersampling: Low-frequency sampling • Nyquist sampling frequency: • Nyquist sampling interval:
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
Supersampling • Subpixels • Increase resolution 22 (10, 20): Maximum Intensity (11, 21): Next Highest Intensity (11, 20): Lowest Intensity 21 20 10 11 12
Pixel-Weighting Masks • Give More Weight to Supixels Near the Center of a Pixel Area 1 2 1 2 4 4 1 2 1
Area Sampling • Set Each Pixel Intensity Proportional to the Area of Overlap of Pixel • 2 Adjacent vertical (or horizontal) screen grid lines trapezoid 22 (10, 20): 90% (10, 21): 15% 21 20 10 11 12
Filtering Techniques • Filter Functions (Weighting Surface) Box Filter Cone Filter Gaussian Filter
Coordinate Reference Frames • 2D Cartesian Reference Frames x y y x
3D Cartesian Reference Frame • Right-Handed v.s. Left-Handed Right-handed Left-handed
3D Curvilinear Coordinate Systems • General Curvilinear Reference Frame • Orthogonal coordinate system • Each coordinate surfaces intersects at right angles
Cylindrical-Coordinate z axis constant : radius of vertical cylinder : vertical plane containing z-axis : horizontal plane parallel to xy-plane y axis Transform to Cartesian coordinator x axis
Spherical-Coordinate z axis constant : radius of sphere : vertical plane containing z-axis : cone with the apex at the origin y axis Transform to Cartesian coordinator x axis
Solid Angle • 3D Angle Defined on a Sphere • Steradian Steradian : Total solid angle : steradian
Points & Vectors • Point • Position in some reference frame • Distance from the origin depends on the reference frame P y Frame B Frame A x
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 :
3D Vector • Magnitude • Directional angle
Vector Addition &Scalar Multiplication • Addition • Scalar multiplication
Vector Multiplication • Scalar Product(Inner Product) Commutative : Distributive : Orthogonal :
Vector Multiplication (cont.) • Vector Product(Cross Product) Noncommutative : Nonassociative : Distributive : Right-handed rule!