please type your answer do not answer it by your handwritin
please type your answer , do not answer it by your handwriting thank you
Question 4 (20 points) What is the method of line-drawing? An example will be useful in explaining this.Solution
Method of line drawing:
The method of line drawing is a graphical tool for approximating and representation a line segment on graphical media. The graphical media, such as fixel based displays and line drawing requires such an approximation. The Basic algorithms requires to indicate lines in one colour. A better representation with multiple colour gradations requires an advanced techniques.
The method of line drawing is a tool for approximating and representation a line segment on graphical media. The graphical media, such as fixel based displays and line drawing requires such an approximation. The Basic algorithms requires to indicate lines in one colour. A better representation with multiple colour gradations requires an advanced techniques.
An example for useful in explain the method of line drawing :
Input the two end points (xi,yi) and (xf,yf)
Compute slope of the line m = (yf – yi) / (xf - xi)
Compute y- intercept of the line b = (yi - mxi)
Set initial values of x and y as x = xi , y = yi
Plot the first end points plot pixel (x,y)
If m<1 then
While X<x
While increment x-coordinate X=x+1
Calculate y coordinate Y= mx+b
Round off the y-value and plot pixel (X,Y)
While (Y < y)
Increment y-coordinate y= y+1
Calculate x-coordinate X=(y-b) / m
Round round off the X value and plot pixel (X,Y)
Let us consider two points (3,4), and (9,5). Find the points to be plotted.
(xi,yi) = (3,4)
(xf,yf) = (9,5)
m = (yf -yi) / (xf -xi)
= (5-4) / (9-3)
= 1/6
b = (yi-mxi)
= 4-(1/6)3
= 7/2
X
Y=mx+b
Plot pixel (x,y)
3
4.0
(3,4)
4
4.17
(4,4)
5
4.33
(5,4)
6
4.5
(6,5)
7
4.66
(7,5)
8
4.83
(8,5)
9
5.0
(9,5)
| X | Y=mx+b | Plot pixel (x,y) | 
| 3 | 4.0 | (3,4) | 
| 4 | 4.17 | (4,4) | 
| 5 | 4.33 | (5,4) | 
| 6 | 4.5 | (6,5) | 
| 7 | 4.66 | (7,5) | 
| 8 | 4.83 | (8,5) | 
| 9 | 5.0 | (9,5) | 


