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

Viewing transformation, Viewing Transformation In previous section, we...

Viewing Transformation In previous section, we have discussed about the geometric transformations as Translation, Shearing, Reflection, Scaling and Rotation. Rotation, Reflect

Lcd - liquid crystal display, LCD - Liquid Crystal Display A liquid...

LCD - Liquid Crystal Display A liquid crystal display consists of two glass plates each containing a light polarizer. One glass plate contains vertical polarizer and the ot

Types of authoring tools in multimedia, Types of Authoring Tools Autho...

Types of Authoring Tools Authoring tools are grouped depends on metaphor used for sequencing or organizing multimedia components and events as: Page or Card Based Tools

What are the utilizations of inverse transformation, What are the utilizati...

What are the utilizations of Inverse transformation? Provide the Inverse transformation for translation, shearing, reflection, scaling and rotation. Solution: We have observed

Combination of positive and negative accelerations, Combination of Positive...

Combination of Positive and Negative Accelerations Actually, it is not that a body once decelerated or accelerated will remain so, although the motion may include both speed-up

Area subdivision method-obscures the continuing two surface, Assume here ar...

Assume here are three polygon surfaces P,Q, R along with vertices specified by as: P: P1(1,1,1), P2(4,5,2), P3(5,2,5) And as Q: Q1(2,2,0.5), Q2(3,3,1.75), Q3(6,1,0.5) R: R1(0.5,

Briefly explain how you could create the gun barrel effect, Question 1: ...

Question 1: (a) Describe what you understand by Rotoscoping in Graphic effects. Give details how Rotoscoping could be achieved in After Effects CS3. (b) Using one algorithm

70, how you doing the graphic?

how you doing the graphic?

Interfacing lcd liquid crystal display, Main Objectives: Interfacing...

Main Objectives: Interfacing LCD to the Micro-controller (PIC18F4520) Programming LCD by using C- language via MPLAB Sending data or command to the LCD Component

Resolution-introduction to computer graphics, Resolution Graphic demons...

Resolution Graphic demonstrations are utilized in presentations to assist convey a concept or express a mood, two kinds of demonstrations graphics are: Vector, and B

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