Transcript
Page 1: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Lecture 4Graphic Primitives, Circle

Page 2: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Drawing Circles

Page 3: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Brute Force Method

Page 4: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Cheating with 8 arcs

Page 5: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Cheating with 8 arcs Implementation

Page 6: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Cheating with 8 arcs Implementation

Page 7: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Digital Differential Analysis - An incremental algorithm

• Does not require sine or cosine table. • based upon calculating the gradient of a circle at a point

and using that to approximate the position of the next point.

Page 8: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Digital Differential Analysis - An incremental algorithm

Page 9: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Digital Differential Analysis - Implementation

Page 10: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Bresenham’s algorithm for circles• Based on limiting the choice of the next pixel to be plotted

to two alternatives, then creating and testing a decision variable to determine which alternative is actually plotted.

• D(Si) and D(Ti) represent the differences between the squared distance between the center of the circle and the middle of pixels S and T . Whichever is smallest corresponds to the pixel that should be plotted.

• To combine the two calculations into one “decision variable” is simply a matter of subtracting the two expressions:

Page 11: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Bresenham’s algorithm for circles

Page 12: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Implementation for Bresenham’s algorithm

Page 13: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Implementation for circles

Page 14: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Implementation for circles

Page 15: Lecture 4 Graphic Primitives, Circle. Drawing Circles

Implementation for circles


Recommended