Download presentation
Presentation is loading. Please wait.
Published byShannon O’Brien’ Modified over 9 years ago
1
1 Circle Drawing Algorithms Pictures snagged from http://accad.osu.edu/~waynec/history/
2
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
3
CS-321 Dr. Mark L. Hornick 3 Cartesian form of Circle Equations (x c, y c ) r Not a very good method. Why?
4
CS-321 Dr. Mark L. Hornick 4 Be the algorithm!
5
CS-321 Dr. Mark L. Hornick 5 What does it do? 0 1 2 3 4 5 6 7 8 01234567891011
6
CS-321 Dr. Mark L. Hornick 6 Polar Coordinate Form (x, y) r Simple method: plot directly from parametric equations θ
7
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
8
CS-321 Dr. Mark L. Hornick 8 Polygon Approximation (x i, y i ) Calculate polygon vertices from polar equation; connect with line algorithm
9
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. 25-30. Bresenham, J. E. A linear algorithm for incremental digital display of circular arcs. Communications of the ACM, 20(2), 1977, pp. 100-106.
10
CS-321 Dr. Mark L. Hornick 10 Bresenham’s Midpoint Circle Algorithm 0<|m|<1 in this region
11
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:
12
CS-321 Dr. Mark L. Hornick 12 Calculating p k+1
13
CS-321 Dr. Mark L. Hornick 13 Recurrence Relation for p k
14
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:
15
CS-321 Dr. Mark L. Hornick 15 Initial Values
16
CS-321 Dr. Mark L. Hornick 16 Bresenham Midpoint Circle Algorithm Summary At each point: If p k < 0: If p k >= 0:
17
CS-321 Dr. Mark L. Hornick 17 Circle Example 1 0 1 2 3 4 5 6 7 8 01234567891011 r = 7
18
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
19
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?)
20
CS-321 Dr. Mark L. Hornick 20 Special Case Ellipses (x c, y c ) rxrx ryry Modified midpoint algorithm possible
21
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.