Draw line segment - digital differential analyzer algorithm, Computer Graphics

Example 1: Draw line segment from point (2, 4) to (9, 9) by using Digital Differential Analyzer algorithm.

Solution: We know usual equation of line is specified via

y = mx+c; here m =( y1 - y0/( x1 - x0)

Specified (x0, y0) → (2, 4) ; (x1, y1) → (9, 9)

⇒ m = ( y1 -y0)/( x1 - x0)

= (9 - 4) /(9 - 2)= 5/7..that is 0< m<1

C = y1- mx1 = 9 - ((5/7)* 9) = (63 - 45)/7 = 18/7

Conversely, by Equation of line (y = mx + c) we have

Y = (5/7)x + (18/7)

DDA Algorithm Two case:

Case 1: m < 1             xi + 1 = xi + 1 yi + 1 = yi + m

Case 2: m > 1             xi + 1 = xi + (1/m)

yi + 1 = yi + 1

Since 0 < m < 1  so as per to DDA algorithm case 1

xi + 1 = xi + 1                   yi + 1 = yi + m

Specified (x0, y0) = (2, 4)

1)      x1 = x0 + 1 = 3

Y1 = y0 + m= 4 +5/7= 4 (5/7)

Place pixel (x0, round y, colour)

That is put on (3, 5)

2) x2 = x1 + 1 = 3 + 1 = 4

y2 = y1 + m = (33/7) +(5/7)

Place on (4, 5)

Likewise go on till (9, 9) is reached.

Posted Date: 4/3/2013 1:49:50 AM | Location : United States







Related Discussions:- Draw line segment - digital differential analyzer algorithm, Assignment Help, Ask Question on Draw line segment - digital differential analyzer algorithm, Get Answer, Expert's Help, Draw line segment - digital differential analyzer algorithm Discussions

Write discussion on Draw line segment - digital differential analyzer algorithm
Your posts are moderated
Related Questions
IMG/MAC/MSP File Formats IMG files were originally implemented to work along with GEM paint program and can handle monochrome and grey level pictures only. MAC files are uti


What is scaling?  The scaling transformations changes the shape of an object and can be carried out by multiplying every vertex (x,y) by scaling factor Sx, Sy where Sx is the

What is clipping? Explain Sutherland Hodgeman polygon clipping algorithm with example.  OR Write the algorithm for Sutherland Hodgeman Polygon. Beginning with the initial set of p

Differentiate between z-buffer method and scan-line method. What is the visibility test made in these methods? Solution : In depth buffer algorithm every pixel location on the

Multimedia: it is the use of different media to present a specific subject. This representation itself is a multimedia presentation implies; it brings together text and graphics.

What are the steps involved in 3D transformation?  Modeling Transformation Projection Transformation Viewing Transformation Workstation Transformation

Disadvantages with the Boundary Representation (i) It requires more storage than the corresponding half-space method. (ii) There is no guarantee that the object created is v

Question: Suppose we have a video monitor with a display area measuring 12.8 inches across and 9.6 inches high.  If the resolution is 1024 by 768 and the aspect ratio is 1, what is

Explain the interactive picture construction techniques.    interactive picture- construction methods are commonly used in variety of applications, including design and painting pa