Several algorithms in computer graphics for two-dimensional line clipping and drawing are analyzed and discussed in this paper. In order to improve the accuracy of plotting and calculation speed, the implementation of these algorithms through experiments in the windows platform by using C language and a DirectDraw interface are done. The comparison of each algorithm performance is made by using different experimental parameters. Analysis results show that accuracy and cost of line clipping can benefit a lot from the process of accumulative errors and to round up or down in division. Experimental results show that by using the optimal tree algorithm for two-dimensional line clipping and the run length slice algorithm for line drawing can efficiently complete the display task. A good reference value for computer graphics can be obtained in this test.%分析与讨论了几种线段二维裁减和绘制算法,为了提高图形绘制的精确度和计算速度,通过实验在Windows平台上利用C语言和DirectDraw接口实现了这些算法.针对不同的实验参数,对各个算法性能作出了比较.分析结果显示:在实现过程中可以对直线裁剪的累计误差处理,对整数除法的四舍五入处理等细节改良,从而使得绘制的图形更加精确,付出的代价非常小.实验结果表明,采用最优树裁剪算法对线段进行二维裁剪并利用步距长度片算法进行绘制,能够高效完成显示任务,结果具有较好的参考价值.
展开▼