第二章02--计算机图形学.pptVIP

  • 0
  • 0
  • 约4.68千字
  • 约 44页
  • 2018-05-15 发布于四川
  • 举报
The algorithm seeks to select the optimum raster locations that represent a straight line. 2. error This algorithm always increments by one unit in x. The increment in y, either zero or one, is determined by examining the distance --error. (x, y +ε)的下一个点为(x, y + ε + m),这里ε为累加误差。可以看出,当ε+m 0.5时,绘制(x + 1, y)点,否则绘制(x + 1, y + 1)点。 So: the algorithm is cleverly constructed so that only the sign of the error term need be examined. error term = (ε+m ) - 0.5 If error term 0, then down; else up. 2. illustrated 4. The initial value of error if the slope of the line is less than 0.5, the error term’s value at the next raster point one unit away, (1,0), is determined by adding the slope of the line to the error term. e = e + m 5. Derivation of formulas: e = e + m e = e + m 6. An example 6. Bresenham’s line rasterization algorithm for the first octant 7. Integer Bresenham’s Algorithm e = e + m Again, incrementing the error term by the slope yields at the next raster point(2,0). e= -1/8 + 3/8 = ? e = e + m When e is positive, which shows that the line passes above the midpoint. The raster element at the next higher vertical location (2,1) better approximates the position of the line; hence y is incremented by one unit. e = e + m - 1 Before considering the next pixel, it is necessary to reinitialize the error term. This is accomplished by subtracting 1 from it, thus e = e - 1, e = ? - 1= - ? Or: e = e + m - 1, e = -1/8 + 3/8 - 1 = ? - 1 e = e + m(Optional) Notice that the intercept of the vertical line at x=2 and the desired line is –0.25 with respect to the line y = 1. Reinitializing to –0.5 relative to zero for the error term yields, as above, -3/4. e = e + m continuing to the next raster unit yields: e = - ? + 3/8 = -3/8 e is negative, thus the y value is not incremented. Error propagation e = e + m From the previous discussion, it is easy to see that the error term is a measure of the y intercept of the desired line at each

文档评论(0)

1亿VIP精品文档

相关文档