2010-12-23 70 views

回答

5
// (cx, cy) is the center of the circle 
// r is the circle radius 
// the smaller the granularity, the better the circle will look 
// to draw only numberOfIterations points, granularity 
// should be 2*pi/numberOfIterations 

for(i=0; i<2*pi; i+=granularity)  
    DrawPoint(cx + r*sin(i), cy + r*cos(i)); 
4

一个为获得一个体面的圆圈更好的算法是布氏圈算法,也称为Midpoint circle algorith

直接的基本圆形例程的问题在于它们倾向于具有别名效果并且看起来不正确,因此该算法提供了更好的逼近,尽管它并不严格符合您的for(;;)循环要求,尽管它是仍然是一个迭代循环。

相关问题