Professional Documents
Culture Documents
POLYNOMIAL ALGORITHM
1 0
1 0
=
=
yi+1 = mxi+1 + b
=m (xi + x) + b
= yi +m x
If x = 1 , then
yi+1 = yi + m
BY: ZEESHAN BHATTI
USING SYMMETRY
For lines with |m| < 1, we are to increment the x value, at each
steps, by unity. For other lines, we increment the y-0values.
If x = 1,
then y = m, where
= m.
= .
If y = 1,
1
then x = , where
DDA ALGORITHM
Digital Differential Analyzer (DDA) algorithm is the simple line generation
algorithm which is explained step by step here.
Step 1 Get the input of two end points (X0,Y0) and (X1,Y1).
Step 2 Calculate the difference between two end points.
dx = X1 - X0
dy = Y1 - Y0
Step 3 Based on the calculated difference in step-2, you need to identify the
number of steps to put pixel. If dx > dy, then you need more steps in x
coordinate; otherwise in y coordinate.
if (dx > dy)
Steps = absolute(dx);
else
Steps = absolute(dy);
10
x0 = 2
x1 = 6
y0 = 5
y1 = 9
Step 2:
dx = x1 - x0
dx = 6-2 = 4
dx= 4
dy = y1 - y0
dy = 9 - 5 = 4
dy=4
11
Step 3:
Because dy is greater than & equal to dx i.e. 4=4, so we use the value of dy
Steps = dy
Steps = 4
Step 4:
xInc = dx / steps
yInc = dy / steps
xInc = 4 / 4 = 1
Step 5:
x = x + xInc
y = y + yInc
2 +1 = 3
5+1 = 6
3+1=4
6+1 = 7
4+1 = 5
7+ 1 = 8
5 +1 = 6
8+1 = 9
yInc = 4 / 4 = 1
BY: ZEESHAN BHATTI
12
13
14
CANDIDATE PIXELS
15
DECISION VARIABLE
16
SOLVING BRESENHAM
Let at any moment the Pixel I(xi, yi) as initial pixel and the next pixel is
(xi+1, yi+1).
Since the pixel are at unit distance, therefore xi+1 = xi +1, but the
value of yi+1 can be P(xi+1, yi) or Q (xi+1, yi+1) depending on the
nearest point of interaction denoted by R(xi+1, yi+1 ), which is the
actual location of the point on the line.
17
18
Step 4:
19
20
P<0
p = p + E
x0 = x0 +1
y0 = y0
p=2
E = 8
NE = -4
2
P => 0
p = p + NE
x0 = x0 +1
y0 = y0+1
(step 1)
3 (step 2)
4 (step 3)
2+(-4) = -2
Step 4:
(step 4)
-2
-2 + 8 = 6
6
6 + (-4) = 2
2
2 +(-4) = -2
-2
-2 +8 = 6
6
6 + (-4) = 2
2
EndWhile
2 +(-4) = -2
-2
10
8
BY: ZEESHAN BHATTI
21
22
p=0
E = 8
NE = -8
P<0
p = p + E
x0 = x0 +1
y0 = y0
P => 0
p = p + NE
x0 = x0 +1
y0 = y0+1
10
16
Step 4:
23
p=0
E = 8
NE = -8
P<0
p = p + E
x0 = x0 +1
y0 = y0
P => 0
p = p + NE
x0 = x0 +1
y0 = y0+1
10
16
11
17
12
17
13
18
14
18
15
19
16
19
17
20
18
20
0 + -8 = -8
-8
-8 + 8 = 0
0
0+ -8 = -8
-8
-8 + 8 = 0
0
0+ -8 = -8
-8
-8 + 8 = 0
0
0+ -8 = -8
-8
24
25
26
27
28
29
xc = yc = 0
So, the equation of circle, i.e. (polynomial equation becomes)
x 2 + y2 = r 2
30
31
-9
P<0
p = p + 4x + 6
x0 = x0 +1
y0 = y0
P => 0
p = p + 4(x-y)+10
x0 = x0 +1
y0 = y0 - 1
-9 + 4(0)+6 = -3
-3
-3 + 4(1)+6= 7
7
7 + 4 (2 5) +10 = 5
5
5 + 4 ( 3-4) +10 = 11
11
32
P<0
p = p + 4x + 6
x0 = x0 +1
y0 = y0
P => 0
p = p + 4(x-y)+10
x0 = x0 +1
y0 = y0 - 1
Step 2:
33
34