#include<iostream>
#include<graphics.h>
#include<conio.h>
using namespace std;
void MidPoint_Circle(const int& x0, const int& y0, const int& r)
{
initgraph(800, 640);
int d = 1 - r, x = 0, y = r;
while (x <= y)
{
cout << "x=" << x << ",y=" << y << ",d=" << d << endl;
putpixel(x + x0, y + y0,RED);
putpixel(x + x0, -y + y0,RED);
putpixel(-x + x0, y + y0, RED);
putpixel(-x + x0, -y + y0, RED);
putpixel(y + x0, x + y0, RED);
putpixel(y + x0, -x + y0, RED);
putpixel(-y + x0, x + y0, RED);
putpixel(-y + x0, -x + y0, RED);
if (d < 0)
{
d += (2 * x + 3);
x++;
}
else
{
d += (2 * x - 2 * y + 5);
x++;
y--;
}
}
_getch();
closegraph();
}
int main(void)
{
MidPoint_Circle(200,200,10);
return 0;
}
中点画圆法(计算机图形学)C++实现
于 2022-05-24 10:39:47 首次发布