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
y-shear about the origin - 2-d and 3-d transformations Suppose an object point P(x,y) be moved to P'(x',y') in the x-direction, through the specified scale parameter 'b'. that

Amiga - Hardware for computer animation Originally owned through Commodore, Amiga computers have conduct a position in the computer animation industry for many years. This is

How many 128 x 8 RAM chips are needed to provide a memory capacity of 4096 16 bits?

Mathematics: There are some area like Probability, combination, permutation, etc.,that can be well explained along with the help of animation, that helps in enhancing the learning

Question 1 Describe the process of formation of image in human eye Structure of the Human Eye Image formation in the Eye Brightness Adaptation and Discrimination

Specified p 0 (1, 1): p 1 (2, 3); p 2 (4, 3); p 3 (3, 1) as vertices of Bezier curve find out 3 points on Bezier curve? Solution : We consider Cubic Bezier curve as: P (

Differences between digital differential analyzer and VECGEN line algorithm?

Refresh Rate: refreshing on raster - scan displays is carried out at the rate of 60 to 80 frames per second, although some system are designed for higher refresh rates. Sometimes,

What are the advantages of laser printer  High speed, precision and economy. Quality printers. .Cheap to handle Lasts for longer time.