Cases for digital differential analyzer algorithm, Computer Graphics

Assignment Help:

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;

X     

}

1347_Cases for Digital Differential Analyzer Algorithm.png

                                                                        Figure: Slope (m) of line is > 1


Related Discussions:- Cases for digital differential analyzer algorithm

What is the purpose behind the staircase effect, 1. What is the purpose be...

1. What is the purpose behind the Staircase effect? Ans. The approximation concerned in the calculation for finding of pixel position concerned in the display of lines and th

Reflection, examples and equation of reflection

examples and equation of reflection

#BLA, #BLA for slope greater and equal to 1

#BLA for slope greater and equal to 1

Line drawing display - random scan display device, Line Drawing Display - R...

Line Drawing Display - Random Scan Display Device The display through this system is termed as Line Drawing Display. The sequence controls the subsequent stages, demonstrated

Image capture formats, Image Capture Formats: Video cameras appear in...

Image Capture Formats: Video cameras appear in two various image capture formats: progressive and interlaced scan. Interlaced Scan It is a technique of enhancing the

What do you understand by the term image compositing, Question 1: (a) E...

Question 1: (a) Explain in detail what you understand by the term image compositing and where it is more often used? (b) You are given 3-5 images to make a photo montage/ima

Mpeg-2 , MPEG-2 : MPEG-2 that is Moving Picture Experts Group format 2 is ...

MPEG-2 : MPEG-2 that is Moving Picture Experts Group format 2 is the standard used through DVD and is of a much higher quality than MPEG- 1. This format gives for 720 x 480 resolu

Explain bresenham''s circle drawing algorithm, Question 1 Explain Bresenha...

Question 1 Explain Bresenham's Circle Drawing Algorithm Question 2 Derive the matrix for inverse transformation Question 3 Discuss the following Raster Graphic Algorithm

Photo and video were determined in the 19th century, Photo and Video were d...

Photo and Video were determined in the 19th century: In books Visuals as add on to texts. They enabled distance education. They developed learning where verbal description was n

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd