程序代写 Bresenham’s line algorithm is used to draw a line from the starting point (

Bresenham’s line algorithm is used to draw a line from the starting point (x0 , y0 )  (20,10) to the end point
(xend , yend )  (30,18). Given the current pixel (xk , yk )
that has been intensified, the next pixel (xk1, yk1) to be
intensified is determined by the decision parameter pk x(dlower dupper), where xxend x0, dlower and
dupper are vertical pixel separations from the mathematical line as shown in Figure P1. Calculate the
decision parameter pk and the next pixel’s coordinates (xk1,yk1) for k0,1,2,3 according to Bresenham’s
line algorithm.
Bresenham’s line algorithm is used to draw a line from the starting point (x0,y0)(5,4) totheendpoint (xend,yend)(20,10). Giventhecurrentpixel (xk,yk)
that has been intensified, the next pixel (xk1, yk1) to be intensified is determined by the decision parameter pk  x(dlower dupper), where x  xend  x0, dlower and dupper
are vertical pixel separations from the mathematical line as shown in Figure P1. Calculate the decision parameter pk and the next pixel’s coordinates (xk1, yk1) for
k  0, 1, 2, 3, 4 according to Bresenham’s line algorithm.
Bresenham’s line algorithm is used to draw a line from the starting point (x0,y0)(10,4) totheendpoint (xend,yend)(25,12). Giventhecurrentpixel (xk,yk)
that has been intensified, the next pixel (xk1, yk1) to be intensified is determined by
the decision parameter pk  x(dlower dupper), where x  xend  x0, dlower and dupper
are vertical pixel separations from the mathematical line as shown in Figure P1. One of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  13.
Calculate the y-coordinate, y p , of this pixel according to Bresenham’s line algorithm.
300029 Engineering Visualization: Tutorial 4
Examples in lecture: Examples in tutorial: Homework:
*Problem 1
Problems with two asterisks (**) Problems with one asterisk (*) All problems for this tutorial
Tutorial 4 Scan Converting Lines and Circles
Dr. J.J. Zou, WSU School of Engineering Page 1

Bresenham’s line algorithm is used to draw a line from the starting point (x0,y0)(5,6) totheendpoint (xend,yend)(15,18). Giventhecurrentpixel (xk,yk)
that has been intensified, the next pixel (xk1, yk1) to be intensified is determined by the decision parameter pk  x(dlower dupper), where x  xend  x0, dlower and dupper
are vertical pixel separations from the mathematical line as shown in Figure P1. One of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  1.
Calculate the y-coordinate, y p , of this pixel according to Bresenham’s line algorithm.
*Problem 5
The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r  10, centred at the
origin. Given the current pixel (xk , yk ) that has been
intensified, the next pixel (xk1, yk1) to be intensified is
determined by the decision parameter p  x2  y2  r2 k
at the mid-point (x, y)  (xk 1, yk  0.5) as shown in Figure P5. Calculate the decision parameter pk and the next pixel’s coordinates (xk1,yk1) for k0,1,2,3 according to the mid-point circle algorithm.
The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r 15, centred at the origin. Given the current pixel (xk , yk ) that has been intensified,
k  0, 1, 2, 3, 4 according to the mid-point circle algorithm.
The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r  8, centred at the origin. Given the current pixel (xk , yk ) that has been intensified,
the next pixel (xk1, yk1) to be intensified is determined by the decision parameter p x2 y2 r2 atthemid-point (x,y)(x 1,y 0.5) asshowninFigureP5.One
of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  3.
Calculate the y-coordinate, yp, of this pixel according to the mid-point circle algorithm.
300029 Engineering Visualization: Tutorial 4
the next pixel (xk1, yk1) to be intensified is determined by the decision parameter p x2 y2 r2 at the mid-point (x,y)(x 1,y 0.5) as shown in Figure P5.
Calculate the decision parameter pk and the next pixel’s coordinates (xk1, yk1) for
Dr. J.J. Zou, WSU School of Engineering Page 2

of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  5.
Calculate the y-coordinate, yp, of this pixel according to the mid-point circle algorithm.
300029 Engineering Visualization: Tutorial 4
The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r  9, centred at the origin. Given the current pixel (xk , yk ) that has been intensified,
the next pixel (xk1, yk1) to be intensified is determined by the decision parameter p x2 y2 r2 atthemid-point (x,y)(x 1,y 0.5) asshowninFigureP5.One
Dr. J.J. Zou, WSU School of Engineering Page 3

*Problem 1
Solutions to Problems in Tutorial 4
Bresenham’s line algorithm is used to draw a line from the starting point (x0 , y0 )  (20,10) to the end point
(xend , yend )  (30,18). Given the current pixel (xk , yk )
that has been intensified, the next pixel (xk1, yk1) to be
intensified is determined by the decision parameter pk  x(dlower dupper), where x  xend  x0, dlower and
dupper are vertical pixel separations from the mathematical line as shown in Figure P1. Calculate the
decision parameter pk and the next pixel’s coordinates (xk1, yk1) for k 0,1,2,3 according to Bresenham’s
line algorithm.
According to Bresenham’s line algorithm : *p0 2yx;
*If pk 0,thennextpixellowerpixel,and
 pk1  pk 2y;
*If pk 0,thennextpixelupperpixel,and
300029 Engineering Visualization: Tutorial 4
 pk 1  pk  2y  2x. p0 2yx2(1810)(3020)6;
For k  0 :
p0 0  Nextpixelupperpixel: x1 x0 121, y1 y0 111.
p0 0  p1  p0 2y2x62(1810)2(3020)2; p10Nextpixelupperpixel:x2 x1122,y2 y1112.
For k  2 :
p1 0  p2  p1 2y2x22(1810)2(3020)2; p2 0  Nextpixellower pixel: x3 x2 123, y3 y2 12.
p2 0 p3 p2 2y22(1810)14; p30Nextpixelupperpixel:x4 x3124,y4 y3113.
Dr. J.J. Zou, WSU School of Engineering

For k  0 :
p0  0  Next pixel  lower pixel : x1  x0 1  6, y1  y0  4.
p0  0  p1  p0  2y  3  2(10  4)  9; p10Nextpixelupperpixel:x2 x117,y2 y115.
For k  2 :
p1 0  p2  p1 2y2x92(104)2(205)9; p2  0  Next pixel  lower pixel : x3  x2 1  8, y3  y2  5.
For k  3 :
p2  0  p3  p2  2y  9  2(10  4)  3;
p3  0  Next pixel  upper pixel : x4  x3 1  9, y4  y3 1  6.
For k  4 :
p3 0  p4  p3 2y2x32(104)2(205)15; p4  0  Next pixel  lower pixel : x5  x4 1  10, y5  y4  6.
300029 Engineering Visualization: Tutorial 4
Bresenham’s line algorithm is used to draw a line from the starting point (x0,y0)(5,4) totheendpoint (xend,yend)(20,10). Giventhecurrentpixel (xk,yk)
that has been intensified, the next pixel (xk1, yk1) to be intensified is determined by the decision parameter pk  x(dlower dupper), where x  xend  x0, dlower and dupper
are vertical pixel separations from the mathematical line as shown in Figure P1. Calculate the decision parameter pk and the next pixel’s coordinates (xk1, yk1) for
k  0, 1, 2, 3, 4 according to Bresenham’s line algorithm. Solution:
According to Bresenham’s line algorithm : *p0 2yx;
*If pk 0,thennextpixellowerpixel,and
 pk1  pk 2y;
*If pk 0,thennextpixelupperpixel,and
 pk1  pk 2y2x. p0 2yx2(104)(205)3;
Dr. J.J. Zou, WSU School of Engineering

For k  0 :
p0  0  Next pixel  upper pixel : x1  x0 1  11, y1  y0 1  5.
p0 0 p1 p02y2x12(124)2(2510)13; p10Nextpixellowerpixel:x2 x1112,y2 y15.
For k  2 :
p1 0 p2 p12y132(124)3;
p2  0  Next pixel  upper pixel : x3  x2 1  13, y3  y2 1  6.
yp y3 6.
300029 Engineering Visualization: Tutorial 4
Bresenham’s line algorithm is used to draw a line from the starting point (x0,y0)(10,4) totheendpoint (xend,yend)(25,12). Giventhecurrentpixel (xk,yk)
that has been intensified, the next pixel (xk1, yk1) to be intensified is determined by the decision parameter pk  x(dlower dupper), where x  xend  x0, dlower and dupper
are vertical pixel separations from the mathematical line as shown in Figure P1. One of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  13.
Calculate the y-coordinate, y p , of this pixel according to Bresenham’s line algorithm. Solution:
According to Bresenham’s line algorithm : *p0 2yx;
*If pk 0,thennextpixellowerpixel,and
 pk1  pk 2y;
*If pk 0,thennextpixelupperpixel,and
 pk1  pk 2y2x. p0 2yx2(124)(2510)1;
Dr. J.J. Zou, WSU School of Engineering

For k  0 :
p0  0  Next pixel  upper pixel : x1  x0 1  4, y1  y0 1  7.
p0 0  p1  p0 2y2x42(186)2(15(5))12; p1  0  Next pixel  lower pixel : x2  x1 1  3, y2  y1  7.
For k  2 :
p1  0  p2  p1  2y  12  2(18  6)  12;
p2  0  Next pixel  upper pixel : x3  x2 1  2, y3  y2 1  8.
For k  3 :
p2 0  p3  p2 2y2x122(186)2(15(5))4; p3  0  Next pixel  lower pixel : x4  x3 1  1, y4  y3  8.
yp y4 8.
300029 Engineering Visualization: Tutorial 4
Bresenham’s line algorithm is used to draw a line from the starting point (x0,y0)(5,6) totheendpoint (xend,yend)(15,18). Giventhecurrentpixel (xk,yk)
that has been intensified, the next pixel (xk1, yk1) to be intensified is determined by the decision parameter pk  x(dlower dupper), where x  xend  x0, dlower and dupper
are vertical pixel separations from the mathematical line as shown in Figure P1. One of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  1.
Calculate the y-coordinate, y p , of this pixel according to Bresenham’s line algorithm. Solution:
According to Bresenham’s line algorithm : *p0 2yx;
*If pk 0,thennextpixellowerpixel,and
 pk1  pk 2y;
*If pk 0,thennextpixelupperpixel,and
 pk1  pk 2y2x. p0 2yx2(186)(15(5))4;
Dr. J.J. Zou, WSU School of Engineering

pk1  pk 2(xk 1)2(yk 1)1. p0 1r1109;
For k  0 :
p0 0  Nextpixelupperpixel: x1 x0 11, y1 y0 10.
p0 0  p1  p0 2(x0 1)192(01)16; p10Nextpixelupperpixel:x2 x112,y2 y110.
For k  2 :
p1 0  p2  p1 2(x1 1)162(11)11;
p2 0  Nextpixelupperpixel: x3 x2 13, y3 y2 10.
p2 0  p3  p2 2(x2 1)112(21)16;
p3 0  Nextpixellower pixel: x4 x3 14, y4 y3 19.
300029 Engineering Visualization: Tutorial 4
*Problem 5
The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r  10, centred at the
origin. Given the current pixel (xk , yk ) that has been
intensified, the next pixel (xk1, yk1) to be intensified is
determined by the decision parameter p  x2  y2  r2 k
at the mid-point (x, y)  (xk 1, yk  0.5) as shown in Figure P5. Calculate the decision parameter pk and the next pixel’s coordinates (xk1,yk1) for k0,1,2,3 according to the mid-point circle algorithm.
According to the mid – point circle algorithm : * ( x0 , y0 )  (0, r)  (0, 10);
*If pk 0,thennextpixelupperpixel,and
 pk1pk2(xk1)1;
*If pk 0,then nextpixellowerpixel,and
Dr. J.J. Zou, WSU School of Engineering

The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r 15, centred at the origin. Given the current pixel (xk , yk ) that has been intensified,
the next pixel (xk1, yk1) to be intensified is determined by the decision parameter p x2 y2 r2 at the mid-point (x,y)(x 1,y 0.5) as shown in Figure P5.
Calculate the decision parameter pk and the next pixel’s coordinates (xk1, yk1) for
k  0, 1, 2, 3, 4 according to the mid-point circle algorithm. Solution:
According to the mid – point circle algorithm : *(x0, y0 )  (0, r)  (0,15);
*If pk 0,thennextpixelupperpixel,and
 pk1pk2(xk1)1;
*If pk 0,then nextpixellowerpixel,and
pk1  pk 2(xk 1)2(yk 1)1. p0 1r11514;
For k  0 :
p0 0  Nextpixelupperpixel: x1 x0 11, y1 y0 15.
p0 0  p1  p0 2(x0 1)1142(01)111; p10Nextpixelupperpixel:x2 x112,y2 y115.
For k  2 :
p10 p2 p12(x11)1112(11)16;
p2 0  Nextpixelupperpixel: x3 x2 13, y3 y2 15.
p2 0  p3  p2 2(x2 1)162(21)11; p30Nextpixellowerpixel:x4 x314,y4 y3114.
For k  4 :
p3 0  p4  p3 2(x3 1)2(y3 1)112(31)2(151)118; p4 0  Nextpixelupperpixel: x5 x4 15, y5 y4 14.
300029 Engineering Visualization: Tutorial 4
Dr. J.J. Zou, WSU School of Engineering

The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r  8, centred at the origin. Given the current pixel (xk , yk ) that has been intensified,
the next pixel (xk1, yk1) to be intensified is determined by the decision parameter p x2 y2 r2 atthemid-point (x,y)(x 1,y 0.5) asshowninFigureP5.One
of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  3.
Calculate the y-coordinate, yp, of this pixel according to the mid-point circle algorithm.
According to the mid – point circle algorithm : * ( x0 , y0 )  (0, r)  (0, 8);
*If pk 0,thennextpixelupperpixel,and
 pk1pk2(xk1)1;
*If pk 0,then nextpixellowerpixel,and
pk1  pk 2(xk 1)2(yk 1)1. p0 1r187;
For k  0 :
p0 0  Nextpixelupperpixel: x1 x0 11, y1 y0 8.
p0 0  p1  p0 2(x0 1)172(01)14; p10Nextpixelupperpixel:x2 x112,y2 y18.
For k  2 :
p1 0  p2  p1 2(x1 1)142(11)11;
p2 0  Nextpixellower pixel: x3 x2 13, y3 y2 17.
yp y3 7.
300029 Engineering Visualization: Tutorial 4
Dr. J.J. Zou, WSU School of Engineering

The mid-point circle algorithm is used to draw the 2nd octant of a circle with radius r  9, centred at the origin. Given the current pixel (xk , yk ) that has been intensified,
the next pixel (xk1, yk1) to be intensified is determined by the decision parameter p x2 y2 r2 atthemid-point (x,y)(x 1,y 0.5) asshowninFigureP5.One
of the pixels to be intensified is located at ( x p , y p ) where the x-coordinate is x p  5.
Calculate the y-coordinate, yp, of this pixel according to the mid-point circle algorithm.
According to the mid – point circle algorithm : * ( x0 , y0 )  (0, r)  (0, 9);
*If pk 0,thennextpixelupperpixel,and
 pk1pk2(xk1)1;
*If pk 0,then nextpixellowerpixel,and
pk1  pk 2(xk 1)2(yk 1)1. p0 1r198;
For k  0 :
p0 0  Nextpixelupperpixel: x1 x0 11, y1 y0 9.
p0 0  p1  p0 2(x0 1)182(01)15; p10Nextpixelupperpixel:x2 x112,y2 y19.
For k  2 :
p10 p2 p12(x11)152(11)10;
p2 0  Nextpixellower pixel: x3 x2 13, y3 y2 18.
p2 0  p3  p2 2(x2 1)2(y2 1)102(21)2(91)19; p3 0  Nextpixelupperpixel: x4 x3 14, y4 y3 8.
For k  4 :
p3 0  p4  p3 2(x3 1)192(31)10;
p4 0  Nextpixellower pixel: x5 x4 15, y5 y4 17.
yp y5 7.
Dr. J.J. Zou, WSU School of Engineering
300029 Engineering Visualization: Tutorial 4