为了提高三维图形系统中直线生成的效率,提出了一种基于直线特性和投影原理的三维直线生成算法.该方法运用直线投影原理,判断出水平方向、垂直方向、±45°方向以及±135°方向等特殊位置的直线.利用三维直线的对称性和方向性,根据特殊位置直线在投影平面上的方向,计算出离直线最近的下一个像素的坐标值,直至生成整条直线.绘制过程中仅判断一次直线方向,避免了Bresenham算法中计算和判断决策参数的运算操作.对于三维空间其余一般位置直线,算法利用三维直线在两个平面上的投影,在Bresenham算法的基础上,分别求出决策参数,计算出直线上各点的坐标值,从而生成直线.实验表明,该算法速度快,效果好.
To increase the speed of line-generating in three-dimensional (3D) graphics system, a new method for 3D line-generating based on line property and projecting was presented. The approach made full use of direction and symmetry of the line and the theory of line projection. By projecting on two-dimensional (2D) planes, directions of thousands of 3D lines whose inclinations were 0°, 180°, ±90°, ±45° and ±135° were judged. According to the direction of the line, the coordinate of the pixel nearest to the line was obtained to generate the whole line directly. In the generating process, the operation of judgment was needed only once, without other operations of renewing the parameter and judging its sign. Remnant lines were projected on 2D planes respectively, and 3D line-generating was simplified to 2D line-generating algorithm. Experiment results showed that the new algorithm has relatively higher efficiency and better stability, and that it also provides a good way to look for effective methods to improve the efficiency of the present 3D CAD&CG algorithms.