You are on page 1of 2

Assignment No: 4

Title: Line Drawing

Objective : 1.To learn basic graphic primitives

2.Applications of DDA & Bresenham Algorithms

Problem Statement:
Write C++/Java program to draw inscribed and Circumscribed circles in the triangle as shown as an
example below. (Use any Circle drawing and Line drawing algorithms)

Theory:

Line/ circle drawing is accomplished by calculating intermediate point co-ordinates along the
line path between two given end points.

1. Accept ( i/p) = (x1 , y1) and the length of side the equilateral triangle ie L
2. x2=x1+L, y2=y
3. x3=(x1+x)/3 y3=y1+h where h is the height of the triangle (h=sqrt(3/4)*L)
4. Draw the triangle with the vertices using DDA algorithm
5. Now calculate centre of the triangle/circles ie Xc=(x1+x)/2, Yc=y1+h/3
6. Radius of the inscribed circle Rin = h/3
7. Draw the Circle using Bresenham’s circle generation algorithm
8. Radius of the circumscribed circle Rcm = 2h/3
Class design

Private:
Int x1, y1,x2,y2,x3,y3;
Public:
Void Line_draw();
Void
Circle_draw(radius,
Xc,Yc);

Fig: Pictorial Representation of Class

Mathematical Model:

Equilateral triangle’s all 3 sides are equal & all interior angles are also equal.

With these properties we can find all 3 points of the triangle

(x1,y1) , (x2,y2),(x3,y3) as

(x1,y1), (x1+L), ((x1+x2)/2,y1+h) where L is the length of 1 side of the triangle

, h is the height of the triangle

Draw the circles using DDA line algorithm

Radius of the inscribed circle Rin = h/3

Radius of the circumscribed circle Rcm = 2h/3

Draw the Circles using Bresenham’s circle generation algorithm

Conclusion: Write atleast 2 points that you learnt during the practical. They may be solving the error
also.

Oral Questions:

1. What is the logic behind creating this design.

You might also like