加入收藏 | 设为首页 | 会员中心 | 我要投稿 衡阳站长网 (https://www.0734zz.cn/)- 数据集成、设备管理、备份、数据加密、智能搜索!
当前位置: 首页 > 服务器 > 系统 > 正文

直线DDA,直线和圆的Bresenham算法

发布时间:2021-01-10 16:08:14 所属栏目:系统 来源:网络整理
导读:? ? ? ? ? ? ? ? ? // DDA.cpp : 定义控制台应用程序的入口点。 // #include " stdafx.h " #include Windows.h #include graphics.h #include conio.h #include math.h void dda_line( int xa, int ya, int xb, int yb, int c); int main( int argc,_TCHAR*

?

#include "stdafx.h"
#include<Windows.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
void CircleBres(int xc,int yc,int radious,int c);
void plot_circle_points(int xc,int x,int y,"");
    CircleBres(100,20,255);
    getch();
    closegraph();
    return 0;
}
void CircleBres(int xc,int c)
{
     int x,p;
     x=0;
     y=radious;
     p=3-2*radious;
     while(x<y){
         plot_circle_points(xc,yc,c);
         if(p<0) p=p+4*x+6;
         else{
         p=p+4*(x-y)+10;
         y-=1;
         } 
     x+=1;
     }
     if(x==y){
         plot_circle_points(xc,c);
     }
}
void plot_circle_points(int xc,int c)
{
    putpixel(xc+x,yc+y,c);
    putpixel(xc-x,c);
    putpixel(xc+x,yc-y,c);
    putpixel(xc+y,yc+x,c);
    putpixel(xc-y,yc-x,c);
}

(编辑:衡阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读