Professional Documents
Culture Documents
Assignment No 1dda-Line
Assignment No 1dda-Line
----------------------------------------------------------------------------------------------------------------
Assignment No: 1
----------------------------------------------------------------------------------------------------------------
Title of the Assignment: Draw the following pattern using DDA Line drawing
algorithms.
----------------------------------------------------------------------------------------------------------------
Prerequisite:
1. Library function of OpenGL
2. Graphical Characteristics of line and Rectangle
---------------------------------------------------------------------------------------------------------------
Objective of the Assignment: To learn how to draw the above mentioned pattern using
DDA Line Drawing Algorithm by taking the lower left and upper right point of the rectangle.
---------------------------------------------------------------------------------------------------------------
Outcomes:
1. Students should understand different equations of the line.
2. Students can able to identify the difference between different line generation algorithms.
---------------------------------------------------------------------------------------------------------------
Software & Hardware Requirements:
Eclipse with Ubuntu Operating System and OpenGL Libraries.
---------------------------------------------------------------------------------------------------------------
Theory:
Scan Conversion:
The process of representing continuous graphics object as a collection of discrete pixels is
called Scan Conversion.
For e.g a line is defined by its two end points & the line equation
For a given x interval Δx along a line, we can compute the corresponding y interval Δy from
Δy = m Δx
Similarly, we can obtain x interval Δx by Δy:
Δx = Δy/m
DDA Line Drawing Algorithm:
1. Start with starting and ending coordinates of the line:(x0, y0) and (x1, y1)
2. Color first pixel (round to nearest integer)
Consider a line from (0,0) to (-5,5) . Use DDA algorithm to rasterize of line.
Solve this Example
1.6Conclusion:
DDA algorithm is an incremental scan conversion method. Here calculations are performed at
each step using the results from the preceding step. The characteristic of the DDA algorithm is to
take unit steps along one coordinate and compute the corresponding values along the other
coordinate. The unit steps are always along the coordinate of greatest change i.e. Dx or Dy.
Practice Assignment:
Draw the following pattern using a Bresenham’s Line drawing algorithms.
Oral Questions:
1. What is the difference between DDA and Bresenham’s Line drawing algorithm?
2. What is the use of abs function in DDA Line drawing algorithm?
3. What is the equation to find slope of the line?
4. What do you mean by sharp slope and steep slope?
5. What will happen for DDA Line drawing algorithm if slope of the line is negative?
6. How to find midpoint of line?