Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
91% found this document useful (11 votes)
11K views

Computer Graphics Example PDF

The document describes using the Bresenham's line algorithm and the Digital Differential Analyzer (DDA) line algorithm to rasterize two lines. For the line from (0,0) to (-8,-4), it shows the tabulated steps of the Bresenham's algorithm with the pixel coordinates, decision variable e, and x and y values. For the line from (3,2) to (4,7), it similarly shows the tabulated steps of the DDA algorithm with iteration number, pixel coordinates, x and rounded x and y values.

Uploaded by

Punam Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
91% found this document useful (11 votes)
11K views

Computer Graphics Example PDF

The document describes using the Bresenham's line algorithm and the Digital Differential Analyzer (DDA) line algorithm to rasterize two lines. For the line from (0,0) to (-8,-4), it shows the tabulated steps of the Bresenham's algorithm with the pixel coordinates, decision variable e, and x and y values. For the line from (3,2) to (4,7), it similarly shows the tabulated steps of the DDA algorithm with iteration number, pixel coordinates, x and rounded x and y values.

Uploaded by

Punam Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Example on Bresenhams algorithm: Consider the line from (0, 0) to (-8,-4), use general

Bresenhams line algorithm to rasterize this line. Evaluate and tabulate all the steps
involved.
Solution:
Given data,
(x1, y1)= (0, 0)
(x2, y2)= (-8,-4)
x=x2-x1=-8-0=8
S1=-1
y=y2-y1=-4-0=4
S2=-1
Decision Variable=e=2*(y)-(x)
e= 2*(4)-(8)
=8-8 =0
e=0

By using general Bresenhams algorithm,


The result in tabulated form as,

Ms. Punam R. Patil

Pixel

Initially (0,0)

(-1,0)

+8

-1

(-2,-1)

-2

-1

(-3,-1)

-8

-3

-1

(-4,-2)

-4

-2

(Computer Graphics & Multimedia)

Page 1

(-5,-2)

+8

-5

-2

(-6,-3)

-6

-3

(-7,-3)

+8

-7

-3

(-8,-4)

-8

-4

By pictorial presentation in graph is as shown below,

(0, 0)

-1

-2

-3

-4

-5

-6

-7

-8

-1
-2
-3
-4
-5
-6

--- This is required solution for the given line using Bresenhams algorithm.

Ms. Punam R. Patil

(Computer Graphics & Multimedia)

Page 2

Example on DDA algorithm: Consider the line from (3, 2) to (4, 7), use DDA line algorithm
to rasterize this line. Evaluate and tabulate all the steps involved.
Solution:
Given data,
1. (x1, y1)= (3, 2)
(x2, y2)= (4,7)
2. To find,
x=x2-x1=4-3=1
y=y2-y1=7-2=5
3. Find out Length by checking condition,
If (dx>=dy) then
length=dx
else
length=dy
end if
Length=y=5
4. x=x/Length =1/5= 0.2
y=y/Length=5/5=1
5. Initial values,
X=x1+0.5*sign (x)
=3+0.5* (+)
X=3.5
Y=y1+0.5*sign (y)
=2+0.5*sign(+)
Ms. Punam R. Patil

(Computer Graphics & Multimedia)

Page 3

Y=2.5
6. Byloop,
The result in tabulated form as,
Iteration

Pixel

R(x)

R(y)

Initially
(3,2)

3.5

2.5

(3,3)

3.7

3.5

(3,4)

3.9

4.5

(4,5)

4.1

5.5

(4,6)

4.3

6.5

Length=5

(4,7)

4.5

7.5

By pictorial presentation in graph is as shown below,

7
6
5
4
3
2
1
(0, 0)
1

Ms. Punam R. Patil

(Computer Graphics & Multimedia)

Page 4

You might also like