Example-1
Draw a circle using Midpoint Circle Algorithm having radius as 10 and center of circle (100,100).
The Algorithm:
S-1: Assume the coordinates of center of the circle as (h,k) and radius =r.
S-2: Find d=1-r and take x=0 & y=r as starting points.
S-3: If d >=0
S-4: If d <0
S-5: Stop when either x or y reaches r/squareroot(2).
S-6: All the other points would be generated by 8 way symmetry (Circle 8 way symmetr).
S-1; Enter the center h=100, k=100 and radius r=10.
S-2: Find d= 1-r , so d=1-10= -9 and take x = 0 , y = 10 (Initial Points as x=0 & y=radius)
S-3: If (d>=0) then x = x +1 and y = y -1 ; d = d + 2*(x-y) + 5;
S-4: if (d <0) then x =x +1 and d = d +2*x + 3;
Where to stop : x or y = 10/sqrt(2) which is 10/1.414= approx = 7. So either x or y reaches 7, the algorithm will stop.
Midpoint Circle Algorithm (r=10,h,k=100) | ||||
Step Number | X | Y | d | Pixel |
1 | 0 | 10 | -9 | (x +h ,y +k) = 100,110 |
2 | 1 | 10 | -9+2*1+3= – 4 | 101,110 |
3 | 2 | 10 | -4+2*2+3=3 | 102,110 |
4 | 3 | 9 | 3+2*(3-9)+5 = -4 | 103,109 |
5 | 4 | 9 | -4+2*4+3 = 7 | 104,109 |
6 | 5 | 8 | 7+2*(5-8)+5 = 6 | 105,108 |
7 | 6 | 7 | Stop | —- |
Rest of the points will be plotted using 8-Way Symmetry. There would be 6*8=48 Points would be created in total, which on joining will look like circle.
Example -2
Draw a circle using Midpoint Circle Algorithm with radius 5.
The Solution:
S-1; Enter the center h=0, k=0 and radius r=5.
S-2: Find d= 1-r , so d=1-5= -4 and take x = 0 , y = 5 (Initial Points as x=0 & y=radius)
S-3: If (d>=0) then x = x +1 and y = y -1 ; d = d + 2*(x-y) + 5;
S-4: if (d <0) then x =x +1 and d = d +2*x + 3;
Where to stop : x or y = 5/sqrt(2) which is 5/1.414= approx = 4. So either x or y reaches 4, the algorithm will stop.
Midpoint Circle Algorithm (r=5,h,k=0) | ||||
Step Number | X | Y | d | Pixel |
1 | 0 | 5 | 1-(5)= -4 | (x +h ,y +k) = 0,5 |
2 | 1 | 5 | -4+2*1+3= 1 | 1,5 |
3 | 2 | 4 | 1+2*(2-4)+5=2 | 2,4 |
4 | STOP |
Rest of the points will be plotted using 8-Way Symmetry. Using this circle will have 8*3 =24 Points, which on joining will look like circle.
NOTES UNIT-2 ENTREPRENEURIAL PLANNING CLASS-XII SUBJECT- ENTREPRENEURSHIP
There are two ways by which you can see some objects colorful, let's say RED…
What is the formula of Lorentz force q = charge B = Magnetic Fields E…
MCQs on Electrostatic Potential & Capacitance - Chapter 2 - Class 12 CBSELove to Learn…
A. Which out of the following are conductors Metal Human Body Animal Bodies Earth All…
MCQs with answer explanation on - Solutions Chapter -2 Class 12 Prepared by Experts MCQ…