计算机图形学:参数方程法或中点法编程绘制圆。

有没有大lao,帮帮我,我这边还没有电脑,解决一下这个问题,采用参数方程法或中点法编程绘制圆,还有,用类似方法绘制奥运五环,希望能给出实验代码截图及运行结果截图,万分感谢

C语言画?

#include <graphics.h>
#include <conio.h>
#include<stdio.h>
void Circle_Midpoint(int x, int y, int r, int color)
{
int tx = 0, ty = r, d = 1 - r;

while(tx <= ty)
{
    putpixel(x + tx, y + ty, color);
    putpixel(x + tx, y - ty, color);
    putpixel(x - tx, y + ty, color);
    putpixel(x - tx, y - ty, color);
    putpixel(x + ty, y + tx, color);
    putpixel(x + ty, y - tx, color);
    putpixel(x - ty, y + tx, color);
    putpixel(x - ty, y - tx, color);

    if(d < 0)
        d += 2 * tx + 3;
    else
        d += 2 * (tx - ty) + 5, ty--;

    tx++;
}

}
void main()
{
int x,y,r;
printf("请输入圆心坐标和半径:\n");
scanf("%d%d%d",&x,&y,&r);
initgraph(640, 480);
Circle_Midpoint((x,y,r, RED);
getch();
closegraph();
}

img

参考一下这个:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>  //定义该数学函数库 因为要用到sqrt函数
#include<iostream>
int main(){
    double y;
    int x,m;
    for(y = 10;y >= -10; y--){
        //圆的半径为10
        //计算y对应的列坐标m,2.03是屏幕纵横比调节系数
        m = 2.03 * sqrt(100-y*y);    //因为屏幕的行距大于列距,不进行调节显示出来的将是椭圆
        for(x = 1;x < 30-m; x++)
            printf(" ");  //图形左侧空白控制
        printf("*"); //左半圆
        for( ;x < 30+m; x++)
            printf(" ");//图形空心部分控制
        printf("*\n");//圆的右侧
    }
    system("pause");
}

结果:

img