Rel*_*lla 3 algorithm geometry point pseudocode
所以我们有一个绘制点的函数DrawPoint(x,y),我们必须绘制一些看起来像圆的点.如何创建这样for(i=0; i<numberOfIterations; i++)画圆圈?
// (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));
Run Code Online (Sandbox Code Playgroud)