Cases for digital differential analyzer algorithm, Computer Graphics

Cases for Digital Differential Analyzer Algorithm

1)  If in case 1, we plot the line another way round that is, moving in y direction via 1 unit every time and after that hunting for x direction pixel that best suits the line. In this condition, all times we look for the x pixel; this will offer more than one option of pixel and hence enhances the defect of the stair case consequence in line generation. Moreover, from the figure of DDA line generation, we notice that in another way round strategy for plotting line 1, the vertical span is fairly less in comparison to the horizontal span. Hence, a lesser number of pixels are to be completed ON, and will be accessible if we increase Y in unit step and may be X. Although more pixels will be accessible if we raise X in unit steps and approximate Y such option will also decrease staircase consequence distortion in line generation, so more motion is to be made beside x-axis.

2) identify a line to be generated from (X0, Y0) to (X1, Y1). If

 (X1 - X 0 > Y1 - Y0) and X1 - X0 > 0 then slope (m) of line is < 1 thus case 1  for line generation is applicable or else case 2, that is If ( X1 - X0  < Y1 - Y0 ) and X1 - X0 > 0 then slope m > 1 and case 2 of line generation is appropriate.

Important: Assume as X1>X0   is true else swap (X0, Y0) and (X1, Y1)

3)   When 0 < m < 1: increment X in unit steps and approximate Y

Unit increment must be iterative ⇒ xi = (xi - 1) + 1 hence (xi, yi) resolves to (xi, mxi + c) or (xi, mxi) . This is to be noticed that whereas calculating yi, if yi became to be a floating number then we round its value to choose the approximating pixel. Such rounding off feature gives to the staircase consequence.

While infinity > m > 1 increment Y in unit steps and estimated X, simplify (xi, yi) as per.

Case 1: slope (m) of line is < 1 or 0 < m < 1

Identify a line to be made from (X0, Y0) to (X1, Y1), suppose that X1>X0 is true else swap (X0, Y0) and (X1, Y1). Now, if (X1 - X0 > Y1 - Y0) it implies slope (m) of line is < 1 thus, case 1 for line generation is valid. Therefore, we require increment X in unit steps and approximating Y. Consequently from X0 to X1 , xi is increased in unit steps in the horizontal direction, there for these unit steps the appropriate value of Y can be estimated through the common equation of line y = mx + c.

Likewise, for case 2, let we discuss for sum up our discussion on Digital Differential Analyzer algorithm for both cases. We will check all cases separately.

1175_Cases for Digital Differential Analyzer Algorithm 2.png

Figure: Slope (m) of line is < 1 (i.e., line 1)

 Sum -up

For illustration, in a specified line the end points are (X0, Y0) and (X1, Y1). Utilizing these end points we determine the slope (m = Y1 - Y0/ X1 - X0) and confirm that the value of m lies among 0 and 1 or is > 1. If 0 < m < 1 so then case 1 applies, else, case 2 applies.

For case 1: increase x in one Unit all times.

For case 2: increase y via one Unit all times and approximate respective values of y and x.

We suppose equation of line is y = mx+c

At x = xi; we have yi = mxi+c

Similarly at x = xi + 1; we have yi + 1 = mxi + 1 +c

Case 1: Slope (m) of line is 0 < m1 (that is line 1)

Because x is to be increase via 1 unit all times

⇒ xi + 1 = xi + 1                            -----------Eq. (1)

Consequently by utilizing equation of line y = mx+c we have yi + 1 = m (xi + 1) +c

= mxi +c + m

= yi + m                        ------------ Eq.(2)


Eq(1) and Eq(2) means that to approximate line for case 1 we should move along x direction via 1 unit to comprise subsequent value of x and we should add slope m to firstly y value to acquire subsequent value of y.

Now, by using the starting point (x0, y0) in the above eq(1) and Eq(2) we go for xi and yi (i = 1, 2, ......n) and place colour to the pixel to be lightened.

This is assumed as X0 < X1 ∴the algorithm goes like:

It is assumed that X0 < X1 ∴the algorithm goes like:

x ← X0

y ← Y0

m ← (Y1 - Y0)/ (X1 - X0)

while (x < = X1) do

{           put-pixel (x, round (y), color)

(new x-value) x ←  (old x-value) x + 1 (new y-axis) y ← (old y-value) y + m


Sample execution of algorithm case 1:

At (x0, y0): put-pixel (x0, y0, colour)

x1 = x0 + 1;        y1 = y0 + m

Likewise, x2 = x1 + 1; y2 = y1 + m

At (x2, y2): put pixel (x2, y2, colour) etc.

Case 2: slope (m) of line is > 1 (that is line 2): Similar as case 1 although, this time, the y component is raised by one unit all times and suitable x component is to be selected. To do the task of suitable selection of x component we utilize the equation of Line: y = mx+c.

Unit increment must be iterative ⇒ yi+1 = yi + 1 ; for this yi+1 we determine consequent xi+1 by utilizing equation of line y = mx + c  and thus get next points (xi+1, yi+1).

⇒ yi + 1 - yi = m (xi + 1 - xi)          ----------- (3)

As y is to be raise by unit steps

∴yi + 1 - yi = 1                           ----------- (4)


By using Eq(4) in (3) we get

⇒ l = m (xi + 1 - xi)                      ----------- (5)

Rearranging here Eq.(5) we obtain:

⇒ 1/m = (xi + 1 - xi)

xi+1 = xi +1/m

Consequently, procedure as a whole for Case 2 is totaled up as Algorithm case 2: suppose Y0 < Y1 the algorithm goes like

Algorithm for case 2:

x ← X0;

y  ← Y0;

m ← (Y1 - Y0)/ (X1 - X0);

m1 ← 1/m;

while (y < Y1) do


put-pixel (round (x), y, colour)

y ← y + 1;

x ← x + m1;



1347_Cases for Digital Differential Analyzer Algorithm.png

                                                                        Figure: Slope (m) of line is > 1

Posted Date: 4/3/2013 1:48:40 AM | Location : United States

Related Discussions:- Cases for digital differential analyzer algorithm, Assignment Help, Ask Question on Cases for digital differential analyzer algorithm, Get Answer, Expert's Help, Cases for digital differential analyzer algorithm Discussions

Write discussion on Cases for digital differential analyzer algorithm
Your posts are moderated
Related Questions
what is zooming and panning in computer graph please explan??

explain cohen sutherland line clipping algorithm

3-D Transformation The capability to represent or display a three-dimensional object is basically to the knowing of the shape of that object. Moreover, the capability to rotat

List out the merits of Plasma panel display?  Merits  Refreshing is not needed Produce a very steady image free of Flicker Less bulky than a CRT. Demerits

Write a C program which takes points as input from mouse clicks (left button) and then performs an action.  Apply your program to generate a closed polygon as follows: Every time a

What is Polygon mesh?  Polygon mesh is a method to show the polygon, when the object surfaces are tiled, it is more convenient to state the surface facets with a mesh function.

QUESTION 1. Describe two methods for converting 16x9 widescreen movie to 4x3. 2. Explain clearly the difference between File Format and Codec. 3. What is a video transiti

Progressive Scan: Progressive or non-interlaced scanning is a process which displays, transmits or stores moving images wherein, the lines of all frame are drawn in order. It is i

Question: (a) Differentiate between lossy and lossless compression. (b) State the uses of the two compression standards MPEG-1 and MPEG-2. (c) State three areas where

Graphics Hardware - Computer aided Design Despite with which advance graphic software you are working along with, if your output device is not well or hardware handling which