0% found this document useful (0 votes)
12 views8 pages

C59 Exp2a

Uploaded by

nikhilkindre1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

C59 Exp2a

Uploaded by

nikhilkindre1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Terna Engineering College

Computer Engineering Department


Program: Sem IV

Course: Computer Graphics

Faculty: Prof.Pradnya Jadhav


LAB Manual
PART A
Experiment No.02
A.1 Aim:
Implement Midpoint Circle Drawing algorithm.

A.2 Prerequisite:
1. C Language

A.3 Outcome:
After successful completion of this experiment students will
be able to

Implement various line, circle, ellipse drawing algorithms.

A.4 Theory:
Derivation of Mid Point Circle Algorithm

Derivation: Assume that a circle is passing through origin and it’s radius is
r . Then the equation of circle will be

x2+y2=r2

F(x,y)=x2+y2-r2

< 0 midpoint is inside.

F(Xmid,Ymid) = = 0 midpoint is on the circle.

> 0 midpoint is outside.

F(Xmid,Ymid) = (X2k+1) + (Yk-1/2)2 – r2


F(Xmid,Ymid) = (Xk+1)2 + (Yk-1/2)2 – r2

F(Xmid,Ymid) = X2k + 2Xk +1 + Y2k –Yk +1/4 -r2

Decision Parameter(Pk) = X2k +Y2k +2Xk –Yk +5/4 -r2

Initial Parameter(Po) = 02 + r2 + 0 – r + 5/4 - r2

Po = 5/4 – r

Pk+1 = X2k+1 + Y2k+1 + 2Xk+1 – Yk+1 + 5/4 – r2

Pk+1 – Pk = (X2k+1 – X2k) + (Y2k+1 – Y2k) + 2(Xk+1-Xk) – (Yk+1-


Yk)

Pk+1 = Pk + (X2k+1 – X2k) + (Y2k+1 – Y2k) + 2(Xk+1-Xk) –


(Yk+1-Yk)

Pk+1 = Pk +(Xk+1 – Xk)(Xk+1 + Xk) +(Yk+1 + Yk)(Yk+1 – Yk) + 2(Xk+1-Xk) –


(Yk+1-Yk) ---A

If P is negative (P<=0)

Xk+1 – Xk = 1

Yk+1 – Yk = 0

Put these value in A

Pk+1=Pk+Xk+1 + Xk +1+1

Pk+1 = Pk + 2Xk+1 + 1

This is the decision parameter for less than zero.

If P is positive (P>0)

Xk+1 – Xk = 1

Yk+1 – Yk = 0

Put these value in A

Pk+1 = Pk + 1(Xk+1 + Xk) + (Yk+1 + Yk)(-1) + 2(1) – (-1)

Pk+1 = Pk + 2Xk+1 – 1 - (Yk+1 + Yk -1 +1) + 3

Pk+1 = Pk + 2Xk+1 – 1 - (2Yk+1 + 1) + 3


Pk+1 = Pk + 2Xk+1 -2Yk+1 + 1

This is the decision parameter for greater than zero.

A.5 Procedure:
Mid-Point Circle ( Xc, Yc, R):

Description:

Here Xc and Yc denote the x – coordinate and y – coordinate of the center of the
circle. R is the radius.

1. Set X = 0 and Y = R

2. Set P = 1 – R

3. Repeat While (X < Y)

4. Call Draw Circle(Xc, Yc, X, Y)

5. Set X = X + 1

6. If (P < 0) Then

7. P = P + 2X + 6

8. Else

9. Set Y = Y – 1

10. P = P + 2(X – Y) + 1 [End of If]

11. Call Draw Circle(Xc, Yc, X, Y) [End of While]

12. Exit

Draw Circle (Xc, Yc, X, Y):

1. Call PutPixel(Xc + X, Yc, + Y)

2. Call PutPixel(Xc - X, Yc, + Y)

3. Call PutPixel(Xc + X, Yc, - Y)

4. Call PutPixel(Xc - X, Yc, - Y)

5. Call PutPixel(Xc + Y, Yc, + X)


6. Call PutPixel(Xc - Y, Yc, + X)

7. Call PutPixel(Xc + Y, Yc, - X)

8. Call PutPixel(Xc - Y, Yc, - X)

9. Exit

PARTB
Roll No. C-59 Name: Nikhil Girish Kindre
Class : C Batch : C3
Date of Experiment: 20 Aug 2024 Date of Submission
Grade :
B.1 Document created by the student:
B.3 Observations and learning:

The Midpoint Circle Drawing Algorithm uses integer calculations


and symmetry to efficiently plot a circle, minimizing floating-point
operations and recalculations. It maintains an error term to
ensure accurate circle drawing with reduced computational
overhead

B.4 Conclusion:
The Midpoint Circle Drawing Algorithm is efficient and accurate for plotting
circles by using integer arithmetic and geometric symmetry, reducing
computational overhead and avoiding floating-point operations.

B.5 Question of Curiosity


Q.1] Plot the circle points r= 50 (xc,yc)=(100,100) Midpoint Circle Drawing
Algorithm?

Q.2] Which are different types of Circle drawing algorithms?

 Different types of circle drawing algorithms include:

1. Midpoint Circle Drawing Algorithm: Uses integer calculations and symmetry to plot
points around the circle.
2. Bresenham’s Circle Drawing Algorithm: An extension of Bresenham’s line algorithm
that uses incremental calculations for efficiency.
3. Parametric Circle Drawing: Uses the parametric equations of a circle to compute and
plot points, typically relying on floating-point arithmetic.
4. DDA (Digital Differential Analyzer) Circle Drawing: Uses differential equations to
compute the circle's points, generally less efficient than the midpoint or Bresenham’s
methods.
5. Polar Coordinates Circle Drawing: Computes circle points using polar coordinates and
then converts them to Cartesian coordinates for plotting.

Q.3] Which are Advantages and Disadvantages of Midpoint Circle drawing


algorithm?

Advantages:
1. Efficiency: Uses integer arithmetic and avoids floating-point calculations, leading to
faster performance.
2. Accuracy: Maintains precision by incrementally adjusting the error term.
3. Simplicity: Straightforward implementation that leverages symmetry to minimize
computations.

Disadvantages:

1. Limited Flexibility: Primarily designed for circle drawing; less adaptable for other
shapes.
2. Pixel Approximation: The algorithm approximates circles with pixels, which may not
perfectly represent circles at low resolutions.
3. Edge Cases: Can be less effective for circles with very large radii or at very high
resolutions.

Q.4]Explain 8-way Symmetry of circle?

 The 8-way symmetry of a circle refers to the property that a circle is symmetric across
eight lines through its center, which divide it into eight equal parts. This includes:

1. 4 Quadrants: Each quadrant of the circle is a mirror image of the others.


2. 4 Axes: The circle is symmetric across the x-axis, y-axis, and two diagonal lines (y = x
and y = -x).
3. 8 way-symmetry - for a circle centered at (0,0) and given that point (x,y) is on the circle,
the following points are also on the circle:
4. (-x, y) , ( x,-y), (-x,-y), ( y, x), (-y, x), ( y,-x), (-y,-x)

5.
6. So it is only necessary to compute the pixels for 1/8 of the circle and then simply
illuminate the appropriate pixels in the other 7/8.

This symmetry allows algorithms to calculate only one-eighth of the circle's points and then
mirror them across these axes, simplifying calculations and reducing computation.

You might also like