3

したがって、点を描画する関数 DrawPoint(x,y) があり、円のように見えるいくつかの点を描画する必要があります。for(i=0; i<numberOfIterations; i++)円を描くように作成する方法は?

4

2 に答える 2

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));
于 2010-12-23T00:12:14.643 に答える
4

適切な円を取得するための優れたアルゴリズムの 1 つは、ブレゼンハムの円アルゴリズムであり、中間点円アルゴリズムとも呼ばれます

単純な基本的な円ルーチンの問題は、それらがエイリアス効果を持つ傾向があり、結果として正しく見えないことです。このアルゴリズムは、ループ要件に厳密には適合しませんfor(;;)が、それでも反復ループですが、より適切な近似を提供します。

于 2010-12-23T00:19:43.790 に答える