用C语言怎么画圆呢?

2020-01-23 14:36发布

请问谁懂C语言画圆的原理?无穷多边形吗
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
26条回答
Jason022
1楼-- · 2020-01-23 15:59
  1. /********************************************/
  2. /* 画圆数学方程(X-Ox)^2+(Y-Oy)^2=Rx^2 */
  3. /********************************************/
  4. void GUI_circle( unsigned char Ox,unsigned char Oy,unsigned char Rx,unsigned char s )
  5. {
  6.     unsigned int xx,rr;
  7.     unsigned int xt,yt;
  8.     unsigned int rs,row,col;
  9.     yt = Rx;
  10.     rr = ( unsigned int )Rx*Rx+1; // 补偿1 修正方形
  11.     rs = ( yt+( yt>>1 ) )>>1; // (*0.75)分开1/8圆弧来画
  12.     for ( xt=0; xt<=rs; xt++ )
  13.     {
  14.         xx = xt*xt;
  15.         while ( ( yt*yt )>( rr-xx ) )
  16.         {
  17.             yt--;
  18.         }
  19.         row = Ox+xt; // 第一象限
  20.         col = Oy-yt;
  21.         LCD_Point( row,col,s );
  22.         row = Ox-xt; // 第二象限
  23.         LCD_Point( row,col,s );
  24.         col = Oy+yt; // 第三象限
  25.         LCD_Point( row,col,s );
  26.         row = Ox+xt; // 第四象限
  27.         LCD_Point( row,col,s );
  28.         //***************45度镜象画另一半***************
  29.         row = Ox+yt; // 第一象限
  30.         col = Oy-xt;
  31.         LCD_Point( row,col,s );
  32.         row = Ox-yt; // 第二象限
  33.         LCD_Point( row,col,s );
  34.         col = Oy+xt; // 第三象限
  35.         LCD_Point( row,col,s );
  36.         row = Ox+yt; // 第四象限
  37.         LCD_Point( row,col,s );
  38.     }
  39. }
复制代码
Etual
2楼-- · 2020-01-23 18:34
 精彩回答 2  元偷偷看……
xivisi
3楼-- · 2020-01-23 22:35
哪里会无穷多边形?  如果显示出来就会被量化成像有限个素点  如果不画出来,那就看你需要的精度(太高精度实在没必要)
lawdown
4楼-- · 2020-01-24 02:49
#include <graphics.h>
void main()
{
        int gdriver=DETECT,gmode;
        initgraph(&gdriver,&gmode,"c:\tc");
        cleardevice();
        moveto(160,120);
        lineto(480,120);
        lineto(480,360);
        lineto(160,360);
        lineto(160,120);
        getch();
        closegraph();
}
y574924080
5楼-- · 2020-01-24 05:19
shamiao
6楼-- · 2020-01-24 06:20
51的麻烦在于需要尽量减少浮点运算,math.h没有十足必要真的别引进来……

一周热门 更多>