Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views3 pages

CG Exp 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

Name : Vaibhav Arun Kokate

Roll No : C23350
Div : 3(C)
Batch : S11

Subject: CGL
Experiment No. 3
Questions :

1. Explain Drawbacks of DDA Line Algorithm ?


Ans : Floating point arithmetic in DDA algorithm is still time consuming.The algorithm is
orientation dependent. Hence end point accuracy is poor. Although DDA is fast, the
accumulation of round-off error in successive additions of floating point increment, however
can cause the calculation pixel position to drift away from the true line path for long line
segment. Rounding-off in DDA is time consuming. There is an extra overhead of using round
off( ) function. Using round off( ) function increases time complexity of the algorithm.
Resulted lines are not smooth because of round off( ) function. The points generated by this
algorithm are not accurate.

2. Explain steps of Bresenham’s Line drawing algorithm.


Ans : Step1: Start Algorithm
Step2: Declare variable x1, x2, y1, y2, d, i1, i2, dx, dy
Step3: Enter value of x1, y1, x2, y2
Where x1, y1 are coordinates of starting point
And x2, y2 are coordinates of Ending point.
Step4: Calculate dx = x2-x1
Calculate dy = y2-y1
Calculate i1=2*dy
Calculate i2=2*(dy-dx)
Calculate d=i1-dx
Step5: Consider (x, y) as starting point and xend as maximum possible value of x.
If dx < 0
Then x = x2
y = y2
xend=x1
If dx > 0
Then x = x1
y = y1
xend=x2
Step6: Generate point at (x,y)coordinates.
Step7: Check if whole line is generated.
If x > = xend
Stop
Step8: Calculate co-ordinates of the next pixel
If d < 0
Then d = d + i1
If d ≥ 0
Then d = d + i2
Increment y = y + 1
Step9: Increment x = x + 1
Step10: Draw a point of latest (x, y) coordinates
Step11: Go to step 7
Step12: End of Algorithm.

3. Discuss DDA Advantages and Disadvantages.


Ans: Adavntages of DDA :
It is a simple and easy-to-implement algorithm. It avoids using multiple operations which
have high time complexities. It is faster than the direct use of the line equation because it
does not use any floating point multiplication and it calculates points on the line.
Disadvantages of DDA :
The algorithm is orientation dependent. Hence end point accuracy is poor. Although DDA is
fast, the accumulation of round-off error in successive additions of floating point increment,
however can cause the calculation pixel position to drift away from the true line path for
long line segment.

4. What is gentle slope and sharp slope ?


Ans: Contour lines are the line on a map joining points of equal height above or below sea
level. When contour lines are closer to each other, then slope is called as sharp slope. When
contour lines are further apart from each other, then slope is gentle slope.

5. How to Calculate Bresenham’s Circle generation ?


Ans: Step1: Start Algorithm
Step2: Declare p, q, x, y, r, d variables
p, q are coordinates of the center of the circle
r is the radius of the circle
Step3: Enter the value of r
Step4: Calculate d = 3 - 2r
Step5: Initialize x=0
&nbsy= r
Step6: Check if the whole circle is scan converted
If x > = y
Stop
Step7: Plot eight points by using concepts of eight-way symmetry. The center is at (p, q).
Current active pixel is (x, y).
putpixel (x+p, y+q)
putpixel (y+p, x+q)
putpixel (-y+p, x+q)
putpixel (-x+p, y+q)
putpixel (-x+p, -y+q)
putpixel (-y+p, -x+q)
putpixel (y+p, -x+q)
putpixel (x+p, -y-q)
Step8: Find location of next pixels to be scanned
If d < 0
then d = d + 4x + 6
increment x = x + 1
If d ≥ 0
then d = d + 4 (x - y) + 10
increment x = x + 1
decrement y = y - 1
Step9: Go to step 6
Step10: Stop Algorithm.

6. Expalin mid-point circle drawing Algorithm ?


Ans: The mid-point circle drawing algorithm is an algorithm used to determine the points
needed for rasterizing a circle. We use the mid-point algorithm to calculate all the perimeter
points of the circle in the first octant and then print them along with their mirror points in
the other octants.
Algorithm:
Step1: Put x =0, y =r in equation 2. We have p=1-r.
Step2: Repeat steps while x ≤ y. Plot (x, y) If (p<0) Then set p = p + 2x + 3. Else. p = p + 2(x-y)
+5. y =y - 1 (end if) x =x+1 (end loop)
Step3: End.
Output.

7. What are the 8 Symmetric points for any point (X,Y) ?


Ans: The most important thing in drawing a circle is learning how the circle is drawn using 8-
way symmetry. It is based on Mirror reflection. The most important thing in drawing a circle
is learning how the circle is drawn using 8-way symmetry. It is based on Mirror reflection.

You might also like