Download presentation

Presentation is loading. Please wait.

Published byWyatt McKinnon Modified over 2 years ago

1
Computer Graphics UNIT-1 Bresenhams Circle Algorithm By &

2
2 Bresenhams Circle Algorithm General Principle The circle function: and Consider only 45° 90°

3
3 Bresenhams Circle Algorithm p1p1 p3p3 p2p2 D(s i ) D(t i ) After point p 1, do we choose p 2 or p 3 ? yiyi y i - 1 xixi x i + 1 r

4
4 Bresenhams Circle Algorithm Define:D(s i ) = distance of p 3 from circle D(t i ) = distance of p 2 from circle i.e.D(s i ) = (x i + 1) 2 + y i 2 – r 2 [always +ve] D(t i ) = (x i + 1) 2 + (y i – 1) 2 – r 2 [always -ve] Decision Parameter p i = D(s i ) + D(t i ) so if p i < 0 then the circle is closer to p 3 (point above) if p i 0 then the circle is closer to p 2 (point below)

5
5 The Algorithm x 0 = 0 y 0 = r p 0 = [1 2 + r 2 – r 2 ] + [1 2 + (r-1) 2 – r 2 ] = 3 – 2r if p i < 0 then y i+1 = y i p i+1 = p i + 4x i + 6 else if p i 0 then y i+1 = y i – 1 p i+1 = p i + 4(x i – y i ) + 10 Stop when x i y i and determine symmetry points in the other octants x i+1 = x i + 1

6
6 Example ipipi x i, y i 0-17(0, 10) 1-11(1, 10) 2(2, 10) 313(3, 10) 4-5(4, 9) 515(5, 9) 69(6, 8) 7(7,7) r = 10 p 0 = 3 – 2r = -17 Initial point (x 0, y 0 ) = (0, 10)

7
7 Exercises Draw the circle with r = 12 using the Bresenham algorithm. Draw the circle with r = 14 and center at (15, 10).

8
8 Decision Parameters Prove that if p i < 0 and y i+1 = y i then p i+1 = p i + 4x i + 6 Prove that if p i 0 and y i+1 = y i – 1 then p i+1 = p i + 4(x i – y i ) + 10

9
9 Advantages of Bresenham circle Only involves integer addition, subtraction and multiplication There is no need for squares, square roots and trigonometric functions

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google