Spring 03 Lecture Set 3 Bresenham Circles Intro to Computer Graphics From Rich Riesenfel Spring 03 More Raster Line Issues Fat lines with multiple pixel with Symmetric lines n point geometry how shoul it look? Generating curves, e.g., circles, etc. Jaggies, staircase effect, aliasing... Spring 03 CS 5600 Generating Circles xploit 8-Point Symmetry ( y, x) ( y, x), y), y), y), y) ( y, x) ( y, x) Once More: 8-Pt Symmetry ( y, x) ( y, x) Only Octant Neee We will generate n Octant, y), y), y), y) ( y, x) ( y, x)
Spring 03 Generating pt (x,y) gives the following 8 pts by symmetry: {(x,y), (-x,y), (-x,-y), (x,-y), (y,x), (-y,x), (-y,-x), (y,-x)} n Octant Is a Goo Arc It is a function in this omain single-value no vertical tangents: slope Lens itself to Bresenham only nee consier or S Implicit q s for Circle Let F(x,y) = x + y r For(x,y) on the circle, F(x,y) = 0 So, F(x,y) > 0 (x,y) Outsie An, F(x,y) < 0 (x,y) Insie Choose or S Function is x + y r = 0 So, F(M) 0 S An, F(M) < 0 F(M) 0 S F(M) < 0 ieal curve M ieal curve M S S
Spring 03 Decision Variable Again, we let, = F(M ) ieal curve Look at Case : M S ol < 0 ol < 0 (, ol F x p y p ) p ) ( y p ) r (, new F x p y p ) ) ( ) p y p r ol < 0 ol < 0 Since, ( 3) new ol x p new ol ( ) ( ) x p x p p x p 3 x p ) p x p ) where, new ol x 3 p,
Spring 03 ieal curve Look at Case : S M S ol 0 S 3 new F p, y p ) 3 ) ( ) p y p r new ol (xp y p 5) Because,, straightforwar manipulation ol 0 S ol 0 S new ol 3 p ) ( y p ) r ( x ) ( y ) r p p new ol 3 p ) ( y p ) xr ( x ) ( y ) r p p x = (x p 3) y p 9 3 y p y p y p = (x p 3) y p 9 3 y p y p y p ol 0 S ol 0 S new ol 3 p ) ( y p ) xr ( x ) ( y ) r p p x = (x p 3) yx p 9 3 y p yx p y p new 9 ( x p 3) ( 3 y p ) ( y ) p From calculation ol From new y-coorinate From ol y-coorinate
Spring 03 I.e., ol 0 S (x y 5) new ol p p ol S x y 5 S p p Note: s Not Constant an S epen on values of x p an y p Summary s are no longer constant over entire line Algorithm structure is exactly the same Major ifference from the line algorithm is re-evaluate at each step Requires real arithmetic Initial Conition Let r be an integer. Start at ( 0, r) Next mipoint M lies at (, r ) So, F r r (, ) ( r ) r 5 r valuation is analogous Structure is same Have to work out the s llipses Getting to Integers Note the previous algorithm involves real arithmetic Can we moify the algorithm to use integer arithmetic?
Spring 03 Integer Circle Algorithm Integer Circle Algorithm Define a shift ecision variable h In the coe, plug in h Now, the initialization is h = - r So the initial value becomes 5 F (, r ) ( r) r Integer Circle Algorithm Then, 0 becomes h Since h an integer h h 0 Integer Circle Algorithm But,h begins as an integer An, h gets incremente by integer Hence, we have an integer circle algorithm Note: Sufficient to test for h < 0 n of Bresenham Circles Another Digital Line Issue Clipping Bresenham lines The integer slope is not the true slope Have to be careful More issues to follow
Spring 03 Line Clipping Problem Clippe Line x x x x max y y max, y ) Clipping Rectangle 0, y0 ), y ) Clipping Rectangle 0, y 0 ) y y x x x x max y y Drawing Clippe Lines Clippe Line Has Different Slope!, y ) m 0, y 0 ) m 3 Pick Right Slope to Reprouce Original Line Segment Pick Right Slope to Reprouce Original Line Segment Zoom of previous situation Zoom of previous situation
Spring 03 Clipping Against x = x x x, Roun ( mx )) B N M mipoint Clipping Against y = y x x B A Line getting clippe y y,( mx B)) Clip Rectangle y y y y y y Clipping Against y = y Situation is complicate Multiple pixels involve at (y = y ) Want all of those pixels as in Analytic, rouning x gives A We want point B Clipping Against y = y Use Line y = y - ½ Roun up to nearest integer x This yiels point B, the esire result Jaggies-Manifestation of Aliasing Ae resolution helps, but oes not irectly aress unerlying issue of aliasing Jaggies an Aliasing To represent a line with iscrete pixel values is to sample finitely a continuous function Jaggies are visual manifestation, artifacts, resulting from information loss The term aliasing is a complicate, unintuitive phenomenon which will be efine later
Spring 03 Jaggies an Aliasing Anti-aliasing Doubling resolution in x an y reuces the effect of the problem, but oes not fix it Doubling resolution costs times memory, memory banwith an scan conversion time! 5 3 0 0 3 5 6 7 8 9 0 Pixel Space Pixel intensity (arkness, in this case) is proportional to area covere by line Anti-aliasing Anti-aliasing Pixel Space Pixel intensity (arkness, in this case) is proportional to area covere by line Set each pixel s intensity value proportional to its area of overlap (i.e. sub-area) covere by primitive Not more than pixel/column for lines with 0 < slope < Gupta-Sproull Algorithm - Gupta-Sproull Algorithm - Stanar Bresenham chooses or N Incrementally compute istance D from chosen pixel to center of line Vary pixel intensity by value of D Do this for line above an below Use coarse (-bit, say) lookup table for intensity : Filter (D,t) Note, Filter value epens only on D an t, not the slope of line! (Very clever) For line_with t = geometry an associate calculations greatly simplify
Spring 03 Cone Filter for Weighte Area Sampling t r D Unit thickness line intersects no more than 3 pixels Observations Lines are complicate Many aspects to consier We omitte many What about intensity of y = x vs y = 0? Lecture Set 3 The n Bresenham Circles