Introduction of Human Body & Structure of cell.pptx
Computer Graphic - Lines, Circles and Ellipse
1.
2. For |m|<1
1. Input 2 line end points and store the left end point
in (x0,y0).
2. Load (x0,y0) into the frame buffer to plot the first
end point.
3. Calculate constants ∆x, ∆y, and 2∆y - 2∆x and 2∆y
and obtain the storing value for the decision
parameter as : P0 = 2∆y - ∆x.
4. At each xk along the line, starting at k = 0, do the
following test: if pk < 0, the next point to plot is
(xk+1, yk) and pk+1 = pk + 2∆y else, the next point to
plot is (xk+1, yk+1) and pk+1 = pk + 2∆y - 2∆x
5. Repeat step 4 ∆x times.
3. Suppose we have the line with the 2 following end
points (20,10) and (30,18) use line drawing algorithm
to draw this line.
m=∆y / ∆x = 8/10 < 1.
Initial point : (20,10)
∆x = 10
∆y = 8
2∆y - 2∆x = -4
2∆y = 16
Initial decision parameter P0 = 2∆y - ∆x =16 – 10 = 6
(30,18)
(20,10)
5. For |m|>=1 Interchange the values of x and y (y is
always increasing in the table and the decision
parameter become :
P0 = 2∆x - ∆y and pk+1 = pk + 2∆x - 2∆y or pk + 2∆x .
6. Suppose we have the line with the 2 following end
points (1,3) and (7,12) use line drawing algorithm to
draw this line.
m=∆y / ∆x = 9/6 > 1.
Initial point : (1,3)
∆x = 6
∆y = 9
2∆x - 2∆y = -6
2∆x = 12
Initial decision parameter P0 = 2∆x - ∆y = 3
(7,2)
(1,3)
8. Suppose we have the line with the 2 following end
points (5,7) and (9,19) use line drawing algorithm to
draw this line.
m=∆y / ∆x = 12/4 > 1.
Initial point : (5,7)
∆x = 4
∆y = 12
2∆x - 2∆y = -16
2∆x = 8
Initial decision parameter P0 = 2∆x - ∆y = -4
(9,19)
(5,7)
10. Suppose we have the line with the 2 following end
points (2,6) and (8,7) use line drawing algorithm to
draw this line.
m=∆y / ∆x = 1/6 < 1.
Initial point : (2,6)
∆x = 6
∆y = 1
2∆y - 2∆x = -10
2∆y = 2
Initial decision parameter P0 = 2∆y - ∆x = -4
(8,7)
(2,6)
12. 1. Input radius r and circle center (xi,yi) and obtain
the first point on the circumference of the circle
centered on the origin as (0,r).
2. Calculate the initial value of decision parameter
as p0 = 5/4 – r (if its integer 1-r).
3. At each xk position starting at k=0, perform the
following test: If pk < 0 then the next point on
circle centered on (0,0) is (xk+1,yk) and pk+1 =
pk+2xk+1+1 else the next point along the circle
centered on (0,0) is (xk+1,yk-1) and pk+1 =
pk+2xk+1+1-2yk+1
4. Repeat step 3 until x>=y.
15. 1. Input rx, ry and ellipse center (xc,yc) and obtain the
first point on an ellipse centered (0,0) on the origins
as (x0,y0) = (0,ry).
2. Calculate the initial value of decision parameter in
region 1 as p10 = ry
2 - rx
2 ry + ¼ rx
2.
3. At each xk position in region 1 starting at k=0,
perform the following test: If p1k < 0 then the next
point along the ellipse centered on (0,0) is (xk+1,yk)
and p1k+1 = p1k+2ry
2xk+1+ry
2 else the next point along
the ellipse centered on (0,0) is (xk+1,yk-1) and p1k+1 =
p1k+2ry
2xk+1+ry
2-2rx
2yk+1.
4. Repeat the steps for region 1 until 2ry
2 xk+1>= 2rx
2
yk+1
16. 4. Calculate the initial value of decision parameter
in region 2 using the last point (x0,y0)
calculated in region 1 as p20 = ry
2 (x0+½)2+rx
2 (y0-
1)2-rx
2ry
2
5. At each yk position in region 2 starting at k=0,
perform the following test: If p2k >= 0 then the
next point along the ellipse centered on (0,0) is
(xk,yk-1) and p2k+1 = p2k-2rx
2yk+1+rx
2 else the next
point along the ellipse centered on (0,0) is
(xk+1,yk+1) and p2k+1 = p2k+2ry
2xk+1-2rx
2yk+1+rx
2.
(Note: Use the same increment value for x and y
in region 1.)
6. Repeat the steps for region 2 until yk+1=0.
17. Given ellipse parameter with rx=8 and ry=6 use
midpoint ellipse drawing to draw an ellipse.
Initial point for region 1 (0,ry)=(0,6).
2ry
2x= 0 (with increment value 2ry
2 = 2(6)2=72)
2rx
2y= 2rx
2ry= 2(8)2(6) (with increment value
–rx
2=-2(8)2=-128)
The initial decision parameter for region 1
p10 = ry
2 - rx
2 ry + ¼ rx
2 =(6)2 - (8)2(6) + ¼(8)2 =-332
19. We now move to region 2
Initial point for region 2 (x0,y0)=(7,3).
The initial decision parameter for region 2
p20 = ry
2 (x0+½)2+rx
2 (y0-1)2-rx
2ry
2
=36(7.5)2+64(2)2-64*36= -151
k pk (xk+1,yk+1) 2ry
2 xk+1 2rx
2 yk+1
0 -151 (8,2) 576 256
1 233 (8,1) 576 128
2 745 (8,0) 576 0
20. Given ellipse parameter with rx=8 and ry=10 use
midpoint ellipse drawing to draw an ellipse.
Initial point for region 1 (0,ry)=(0,10).
2ry
2x= 0 (with increment value 2ry
2 = 2(10)2=200)
2rx
2y= 2rx
2ry= 2(8)2(10) (with increment value
–rx
2=-2(8)2=-128)
The initial decision parameter for region 1
p10 = ry
2 - rx
2 ry + ¼ rx
2
=(10)2 - (8)2(10) + ¼(8)2 =-524