






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Bresenham’s Line Algorithm ^
Can be adapted for circles and curves
^
^
Testing sign of an integer parameter to determinewhich pixel is closer tothe actual line path
NE M Q
P(x
, yp
)p^
E
Bresenham
’s Line Algorithm
^
Accurate and Efficient ^
^
^
Case) Positive Slope Less Than 1 ^
k+
Bresenham
’s Algorithm(cont.)
^
^
k
^
Difference ^
Decision parameter
^
^
b
x m y^
k^
^
1
^
k
k
k^
1
^
^
k
k
k^
2
d^1
-^
d^2
< 0
( x
+1,k
y
)k
d^1
-^
d^2
> 0
( x
+1,k
y
+1)k
^
^
c y x x y b x y y x x y
d d x
p
k
k
k
k
k
2 1
Bresenham
’s Algorithm(cont.)
^
Algorithm for 0<
m
<
^
Input the two line endpoints and store the left end point in (
x^0
,^ y
) 0
^
Load (
x,^0
y^0
) into the frame buffer; that is, plot the first point
^
Calculate constants
Δ
x,^
Δy
,^2
Δy
, and
2
Δy
−^
2 Δ
x, and obtain the
starting value for the decision parameter as ^
At each
x^ k
along the line, start at
k^
=
, perform the following test:
^
If^ p
< 0k^
, the next point to plot is (
x+1k
,^ y
) andk
^
Otherwise, the next point to plot is (
x+1k
,^ y
+1k
) and
^
Repeat step 4
Δ
x^ times
x
y
p^
0
y
p
p^
k
k^
^
1
x
y
p
p^
k
k^
^
1
Bresenham’s Line Drawing Algorithm ^
The above algorithm works for slopesbetween 0 and 1 ^
If slope is greater than 1, we interchange theroles of x and y directions as in DDA ^
^
Whenever there is a tie between candidatepixels, we make sure that the same policy isfollowed
Line Function ^
A function for line drawing may be available for a variety ofgraphical packages ^
OpenGL ^
PHIGS
^
They fundamentally use the same algorithms ^
DDA ^
Besenham’s algorithms
^
Relative coordinate specifications may be employed or absolute ^
Conversions may be made between modelling coordinates toworld coordinates to normalized coordinates to devicecoordinates ^
A line drawing may be divided into portions and each successivecall may draw parts of the line between two points