cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 2701|回复: 6

[求助] 这段画圆的程序哪儿错了

[复制链接]
发表于 2012-11-24 10:46:59 | 显示全部楼层 |阅读模式
这段画圆的程序哪儿错了
int fillcircle(int x,int y,int r)
{
     int fx,fy;
     for(fx=x-r;fx<=x+r;fx++){
      fy=sqrt(r^2-(fx-x)^2)+y;
      Bdisp_DrawLineVRAM( fx, 2*y-fy, fx, fy);
    }
}
 楼主| 发表于 2012-11-24 10:53:41 | 显示全部楼层
y=√(〖r^(2-) (x-x_0 )〗^2+) y_0
用的是此公式
 楼主| 发表于 2012-11-24 10:58:44 | 显示全部楼层
f:\0.png
 楼主| 发表于 2012-11-24 11:00:10 | 显示全部楼层
这个

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2012-11-24 12:45:53 来自手机 | 显示全部楼层
建议换成参数方程,会好用很多来自: Android客户端
发表于 2012-11-24 17:41:09 | 显示全部楼层
本帖最后由 GWHBOB 于 2012-11-24 17:42 编辑

  1. #include <mathf.h>
  2. #define step 2//每隔2像素画一道线
  3. const pi=3.14159
  4. //
  5. void circle(float x,float y,float r)
  6. {
  7.   float x0,y0,x1,y1,t,tstep;

  8.   x0=x+r;y0=y;
  9.   tstep=step/r;
  10.   for(t=tstep;t<2*pi;t+=tstep){
  11.     x1=x+r*cosf(t);y1=y+r*sinf(t);
  12.     line(x0,y0,x1,y1);
  13.     x0=x1;y0=y1;
  14.   }
  15. }
复制代码
 楼主| 发表于 2012-11-24 19:06:23 | 显示全部楼层
tks.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cnCalc计算器论坛

GMT+8, 2024-4-25 22:46 , Processed in 0.073798 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表