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
what is vecgen algorithm and bresenham linequestion..

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

In contrast to depth-buffer method, here we identify one surface at one time, scan-line method deals along with multiple surfaces. Since it processes each scan-line at one time, al

Animated GIF: For combining various GIF images in a particular file to create animation, GIF file format is used. There are several drawbacks to such functionality. The form

Delta-Delta Arrangement and In-Line Arrangement There are two types of shadow masks available, delta-delta arrangement and in-line arrangement. The in-line arrangement refers t

Ellipse generating algorithm: Algorithm is similar to circle algorithm. We divide the ellipse on the positive quadrant into two regions. Region 1 where the slope > -1, and Reg

Question: (a) Write a short note on the dot syntax as used in actionScript. (b) A data type describes the kind of information a variable or ActionScript element can hold.

Q.  Write a short note on area subdivision method for hidden surface removal.   Ans. Area Subdivision This technique for hidden- surface removal is essentially an image- spac

Boundary Fill Algorithm Boundary fill algorithm is suitable when the boundary has single color while flood fill algorithm is more suitable for filling regions which are defined

Illustration: Find the normalization transformation N that uses the rectangle W (1, 1), X (5, 3), Y (4, 5) and Z (0, 3) as a window and also the normalized device screen like the