1 Circle Drawing Algorithms Pictures snagged from
2 Drawing Circles and Arcs Similar to line drawing In that you have to determine what pixels to activate But non-linear Simple equation implementation Optimized
CS-321 Dr. Mark L. Hornick 3 Cartesian form of Circle Equations (x c, y c ) r Not a very good method. Why?
CS-321 Dr. Mark L. Hornick 4 Be the algorithm!
CS-321 Dr. Mark L. Hornick 5 What does it do?
CS-321 Dr. Mark L. Hornick 6 Polar Coordinate Form (x, y) r Simple method: plot directly from parametric equations θ
CS-321 Dr. Mark L. Hornick 7 Trig functions are expensive Plots of first 1, 3, 5, 7, 9, 11, and 13 terms in the Taylor’s series for sin
CS-321 Dr. Mark L. Hornick 8 Polygon Approximation (x i, y i ) Calculate polygon vertices from polar equation; connect with line algorithm
CS-321 Dr. Mark L. Hornick 9 The Bresenham Algorithms Bresenham, J. E. Algorithm for computer control of a digital plotter, IBM Systems Journal, 4(1), 1965, pp Bresenham, J. E. A linear algorithm for incremental digital display of circular arcs. Communications of the ACM, 20(2), 1977, pp
CS-321 Dr. Mark L. Hornick 10 Bresenham’s Midpoint Circle Algorithm 0<|m|<1 in this region
CS-321 Dr. Mark L. Hornick 11 The Circle Decision Parameter Calculate f circle for point midway between candidate pixels xkxk ykyk If p k < 0: If p k >= 0:
CS-321 Dr. Mark L. Hornick 12 Calculating p k+1
CS-321 Dr. Mark L. Hornick 13 Recurrence Relation for p k
CS-321 Dr. Mark L. Hornick 14 One Last Term … If y k+1 = y k, then: If y k+1 = y k -1, then:
CS-321 Dr. Mark L. Hornick 15 Initial Values
CS-321 Dr. Mark L. Hornick 16 Bresenham Midpoint Circle Algorithm Summary At each point: If p k < 0: If p k >= 0:
CS-321 Dr. Mark L. Hornick 17 Circle Example r = 7
CS-321 Dr. Mark L. Hornick 18 Symmetry Optimization (a, b) (b, a) (a, -b) (b, -a) (-b, a) (-b, -a) (-a, b) (-a, -b) Calculate points for one octant; replicate in other seven
CS-321 Dr. Mark L. Hornick 19 General Ellipse Equation In general, ellipse described by constant sum of distances from foci Difficult to solve equations and plot points (use parametric polar form?)
CS-321 Dr. Mark L. Hornick 20 Special Case Ellipses (x c, y c ) rxrx ryry Modified midpoint algorithm possible
CS-321 Dr. Mark L. Hornick 21 Drawing Ellipses General ellipses Polygon approximation Rotation (we’ll defer this until later, when we cover coordinate transformations) Aligned axes Constrained (no rotation) Midpoint algorithm