資源簡介
懸掛運動控制系統 畫圓程序 點到點 以及 循跡運動

代碼片段和文件信息
#include“circle_sport.h“
#include“math.h“
#include“motor_sport.h“
#include“dian_to_dian_sport.h“
#include“key.h“
#define???uchar???unsigned??char
#define???FALSE????????(0)
#define???TRUE?????????(1)
#define???R????????????(25)
#define???L????????????(1)
//float???Cur_x1Cur_y1;//起始???畫圓點
static??float???Cur_xCur_y;????????//圓上點的坐標臨時值????????????????????????????
float???circle_centre_x=30??circle_centre_y=40;??????//圓心坐標
uchar???circle_mode;
int??second=0;
uchar??flag=0;
void?bresenham_circle?(void)
{float???xy;
?static?float??p;
?uchar?phase;????
?uchar???flag_p_change;
?static?uchar?last_phase;
//?static??int??i=1;
//while(circle_mode)
//{????
??x?=?Cur_x-circle_centre_x; ???//Cur_xCur_y為圓上坐標??,X0,Y0為圓心坐標
??y?=?Cur_y-circle_centre_y;??
?if?(x>0) ???????//判斷象限
????{
?????if?(y>0)
????????{?if?(x>y)
????????????phase?=?2;
??????????else
????????????phase?=?1;
????????}
?????else
????????{?if?(x>(-y))
????????????phase?=?3;
??????????else
????????????phase?=?4;
????????}
????}
??else
????{
??????if?(y>0)
????????{?if((-x)>y)
????????????phase?=?7;
??????????else
????????????phase?=?8;
????????}
?????else
????????{?if?(x>y)
????????????phase?=?5;
??????????else
????????????phase?=?6;
????????}
????}
??if?(x==0?&&?y>0)?phase?=?1; //對象限交界處作具體處理
??if?(x==y?&&?x>0)?phase?=?2;
??if?(y==0?&&?x>0)?phase?=?3;
??if?(x==(-y)&&?x>0)?phase?=?4;
??if?(x==0?&&?y<0)?phase?=5;
??if?(x==y?&&?x<0)?phase?=6;
??if?(y==0?&&?x<0)?phase?=7;
??if?((-x)==y?&&?x<0)phase?=8;
??if?(last_phase!=?phase) //判斷是否進入新的象限
????{?flag_p_change?=?TRUE; ??????//進入,打開p值初始值允許位
???????second++;
??????last_phase?=?phase;}
?????//?motor_sport_start(?Cur_x?Cur_y);
??switch?(phase)
??{
???case?1:{
???????????if?(flag_p_change) ??????//第一次進入第一象限
???????????{
?????????????p?=2*(x+L)*(x+L)?+?2*y*y-2*y-2*R*R?+L*L;//給p賦初值
?????????????flag_p_change?=?FALSE;
?????????????//second++;
???????????}
???????????if?(p?0)?p=p+4*(x+L)*L+2*L*L; ??????//非第一次,迭代
???????????else?{p=p+4*(x-y)*L+10*L*L;y=y-L;}
???????????x=x+L;
??????????}break;
???case?2:{
???????????if?(flag_p_change) ??????//第一次進入第二象限
???????????{
?????????????p?=?2*(y-L)*(y-L)?+?2*x*x?+?2*x-2*R*R+L*L;//給p賦初值
?????????????flag_p_change?=?FALSE;
???????????}
???????????if?(p?0){p=p+4*(x-y)*L+10*L*L;x=x+L;}??//非第一次,迭代
???????????else?p=p-4*(y-L)*L+2*L*L;
???????????y=y-L;
??????????}break;
???case?3:{
???????????if?(flag_p_change)
???????????{
?????????????p?=?2*(y-L)*(y-L)?+?2*x*x-2*x-2*R*R?+?L*L;
?????????????flag_p_change?=?FALSE;
???????????}
???????????if?(p?0)?p=p-4*(y-L)+2*L*L;
???????????else??{p=p-4*(x+y)+10*L*L;x=x-L;}
???????????y=y-L;
??????????}break;
???case?4:{
???????????if?(flag_p_change)
???????????{?
?????????????p?=?2*(x-L)*(x-L)?+?2*y*y-2*y-2*R*R?+L*L;
?????????????flag_p_change?=?FALSE;
???????????}
???????????if?(p?0)?{p=p-4*(x+y)+10*L*L;y=y-L;}
???????????else??p=p-4*(x-L)+
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????17846??2011-05-09?21:54??主程序test\主程序test\主程序test\jianpanmodel\Backup?(2)?of?ssd.ewd
?????文件??????48134??2011-05-09?21:54??主程序test\主程序test\主程序test\jianpanmodel\Backup?(2)?of?ssd.ewp
?????文件??????17863??2011-05-10?21:26??主程序test\主程序test\主程序test\jianpanmodel\Backup?(3)?of?ssd.ewd
?????文件??????48264??2011-05-10?21:26??主程序test\主程序test\主程序test\jianpanmodel\Backup?(3)?of?ssd.ewp
?????文件??????17863??2011-05-07?22:07??主程序test\主程序test\主程序test\jianpanmodel\Backup?of?ssd.ewd
?????文件??????48218??2011-05-07?21:34??主程序test\主程序test\主程序test\jianpanmodel\Backup?of?ssd.ewp
?????文件???????5733??2011-05-11?16:31??主程序test\主程序test\主程序test\jianpanmodel\circle_sport.c
?????文件????????168??2011-05-10?19:10??主程序test\主程序test\主程序test\jianpanmodel\circle_sport.h
?????文件??????47593??2011-05-11?21:34??主程序test\主程序test\主程序test\jianpanmodel\Debug\Exe\ssd.d43
?????文件??????31921??2011-05-11?21:34??主程序test\主程序test\主程序test\jianpanmodel\Debug\Exe\XUANGUA.HEX
?????文件?????125942??2011-05-11?16:31??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\circle_sport.r43
?????文件??????57183??2011-05-11?12:26??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\dian_to_dian_sport.r43
?????文件???????7929??2011-05-11?12:26??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\dot.r43
?????文件???????7396??2011-05-11?12:26??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\free_sport.r43
?????文件??????12412??2011-05-11?21:34??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\keyscan.r43
?????文件???????5411??2011-05-11?12:26??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\line_sport.r43
?????文件??????11171??2011-05-11?21:34??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\main.r43
?????文件??????36092??2011-05-11?12:26??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\motor_sport.r43
?????文件???????1001??2011-05-11?20:54??主程序test\主程序test\主程序test\jianpanmodel\Debug\Obj\ssd.pbd
?????文件???????6440??2011-05-10?13:52??主程序test\主程序test\主程序test\jianpanmodel\dian_to_dian_sport.c
?????文件????????221??2011-05-09?12:09??主程序test\主程序test\主程序test\jianpanmodel\dian_to_dian_sport.h
?????文件??????13913??2011-05-07?15:11??主程序test\主程序test\主程序test\jianpanmodel\dot.c
?????文件????????188??2011-05-07?15:11??主程序test\主程序test\主程序test\jianpanmodel\dot.h
?????文件???????1272??2011-05-10?11:47??主程序test\主程序test\主程序test\jianpanmodel\free_sport.c
?????文件????????189??2011-05-07?14:28??主程序test\主程序test\主程序test\jianpanmodel\free_sport.h
?????文件????????189??2011-05-09?09:41??主程序test\主程序test\主程序test\jianpanmodel\key.h
?????文件???????1789??2011-05-11?21:34??主程序test\主程序test\主程序test\jianpanmodel\keyscan.c
?????文件????????966??2011-05-09?22:09??主程序test\主程序test\主程序test\jianpanmodel\line_sport.c
?????文件????????165??2011-05-07?21:35??主程序test\主程序test\主程序test\jianpanmodel\line_sport.h
?????文件???????1539??2011-05-11?21:34??主程序test\主程序test\主程序test\jianpanmodel\main.c
............此處省略25個文件信息
- 上一篇:語音播報 簡單(源碼)
- 下一篇:ise9.1注冊碼
評論
共有 條評論