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

Compare bresenham line generation algorithm with dda, 1. Compare Bresenham...

1. Compare Bresenham line generation with Digital Differential Analyzer line generation. Ans.   Bresenham line generation algorithm is better than Digital Differential Analyze

Steps of cohen sutherland line clipping algorithm, Cohen Sutherland line cl...

Cohen Sutherland line clipping algorithm The algorithm uses the following main steps Divide the entire plane into nine disjoint regions using the four window boundaries

Graphics image processing-image processing, Graphics Image Processing: The...

Graphics Image Processing: The most generally utilized software is: Photoshop. Characteristics: I.          Most general image processing software. II.         Focuses upon

Transformation for 3-d rotation, Transformation for 3-D Rotation Rotat...

Transformation for 3-D Rotation Rotation in 3-dimensions is considerably more complicated then rotation in 2-dimensions. In 2-Dimentional, a rotation is prescribed via an angl

Handling mouse input, When you set up your project, create the class as an ...

When you set up your project, create the class as an "ACM Graphics Program", rather than a plain class. This will perform the necessary preparations for you to use mouse input in y

List out the various text clipping, List out the various Text clipping?  ...

List out the various Text clipping?  All-or-none string clipping -if all of the string is inside a clip window, keep it or else discards. All-or-none character clipping - disca

Sound and audio, Sound and Audio: Sound is a mechanical energy distur...

Sound and Audio: Sound is a mechanical energy disturbance which propagates by matter as a wave. Sound is characterized through the various properties that are: frequency, per

Education, Education, Training, Entertainment and Computer Aided Design ...

Education, Training, Entertainment and Computer Aided Design CAD or CADD is an acronym which depending upon who you ask, can stand for: I. Computer Assisted Design. II.

Jas file formats, JAS: The JAS file formats were implemented to form the s...

JAS: The JAS file formats were implemented to form the smallest possible picture files for 24bits per pixel image and 8 bit per pixel gray scaled pictures. This uses a discrete co

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