Subj : Re: I need you advice and talent To : borland.public.cpp.borlandcpp From : john blackburn Date : Wed May 05 2004 11:06 am I think you're asking a lot here, the purpose of the newsgroups is to help people with issues and problems with Borland compilers/IDE and not as a general programming development resource. DDA usage is fairly specialized and you need to find a newsgroup that looks at mathematical issues like this. Use google to locate links relative to DDA method and from them try to find a more relevant newsgroup; you'll be much more successful this way. One comment I would make: I have in the past worked on the development of hardware DDA technology i.e. creating hardware implementations of digital integrators, summers, multipliers etc. for solving differential equation equations. The one overriding important issue was the accuracy of the integration algorithm and maybe you should have a look at that in your software DDA method. John Jackzhang wrote: > > I am sorry to trouble everyone but I have a very important question and I > must resolve it as quickly as possible so I need your advice.And the > question is :how can I draw a circle corrently.My program follows: > #include > #include > #include > #include > #include > #include "driver.h" > #include "composit.h" > #include "updown.h" > #define ty_speed 4000 > #ifdef __cplusplus > extern "C" > { > #endif > void G0203TG(); > void setg0203(); > void wayg02(); > void wayg03(); > #ifdef __cplusplus > } > #endif > extern upprocess(int); > extern downprocess(); > extern composition(); > extern FEED_BACK1; > extern PLANE1_FLAG; > extern long X_COUNT,Y_COUNT,Z_COUNT,X_AXIE,Y_AXIE,Z_AXIE, > X_CENTER,Y_CENTER,Z_CENTER; extern ALL_END; > extern int G00_Speed; > extern char Simulation_Flag; > extern unsigned int Simulation_Speed; > extern unsigned int test_speed; > extern updown *ud; > extern driver *dr; > extern compensation *jx; > extern int X_reginal,Y_reginal,Z_reginal ;//from composit.cpp > extern int X_derect,Y_derect,Z_derect;//from composit.cpp > extern char flag; > extern uptable *ty_ut; > extern int Ty_pause_Flag; > extern int continue_flag; > extern int Ty_esc_flag; > extern int Darwinist_times; > extern char Dar_forb_flag; > extern int current_speed; > extern long distance,max_count; > > long OpStPoint_x, OpStPoint_y, OpStPoint_z; > long integrator_x, integrator_y, integrator_z; > long X_TOTAL,Y_TOTAL,Z_TOTAL; > long Constant; > long sum_integrator_x, sum_integrator_y,sum_integrator_z; > float radils; > char overflow_flag_x, overflow_flag_y, overflow_flag_z; > char wayflag; > void wayg02() {wayflag=1;} //operation direction > void wayg03() {wayflag=-1;} > void setg0203() > { > ty_ut=ud->read_uptable(); > int m=0,n=55; > int find_flag=1; > max_count=0; distance=0; > test_speed=FEED_BACK1; > FEED_BACK1=test_speed*(1+Darwinist_times/20.0); //Darwinist_times > if(FEED_BACK1>=G00_Speed) FEED_BACK1=G00_Speed; > ud->set_multiple(1); > sum_integrator_x=0; sum_integrator_z=0; sum_integrator_y=0; > X_TOTAL=labs(X_COUNT); Y_TOTAL=labs(Y_COUNT); > Z_TOTAL=labs(Z_COUNT); > OpStPoint_x=-X_CENTER; OpStPoint_y=-Y_CENTER; > OpStPoint_z=-Z_CENTER; > > radils=sqrt(OpStPoint_x*OpStPoint_x+OpStPoint_y*OpStPoint_y+OpStPoint_z*OpStPoint_z); > Constant=long(radils+0.5); > switch(PLANE1_FLAG) //chose the opetation surface > { > case 1: > integrator_x=wayflag*(-OpStPoint_y)/ud->read_multiple(); > integrator_y=wayflag*OpStPoint_x/ud->read_multiple(); > integrator_z=0; > break; > case 2: > integrator_x=wayflag*(-OpStPoint_z)/ud->read_multiple(); > integrator_z=wayflag*OpStPoint_x/ud->read_multiple(); > integrator_y=0; > break; > case 3: > integrator_y=wayflag*(-OpStPoint_z)/ud->read_multiple(); > integrator_z=wayflag*OpStPoint_y/ud->read_multiple(); > integrator_x=0; > break; > } > > max_count=max(X_TOTAL,Y_TOTAL); > max_count=max(max_count,Z_TOTAL); > max_count=max_count*ud->read_multiple(); > do{ > if(max_count>=2*ud->read_multiple()*ty_ut[n].sigam) break; > else if(max_count>=2*ud->read_multiple()*ty_ut[n-1].sigam) > {if(FEED_BACK1>=ty_ut[n-1].feed) > FEED_BACK1=ty_ut[n-1].feed; > break;} > n--; > }while(n>=1) ; > if(n==0) FEED_BACK1=ty_ut[0].feed; > do{ > if(FEED_BACK1<=ty_ut[m].feed) > { distance=ud->read_multiple()*ty_ut[m].sigam; > find_flag=0; > } > m++; > }while(find_flag) ; > if(Simulation_Flag) ud->set_speed(Simulation_Speed); > else ud->set_speed(FEED_BACK1); > > ud->set_updown_flag(Up_And_Down); > dr->set_forbidden_tag(Simulation_Flag); > } > > void G0203TG() > { > if(Ty_pause_Flag&&Ty_esc_flag) > if(ud->read_play_speed()<=100) > return; > jx->judge( X_derect, Y_derect, Z_derect, X_reginal,Y_reginal,Z_reginal); > if(jx->read_compflag()) > if(jx->execute()) > return; > > max_count--; > flag=ud->execute();//the fuction is used for determin the > 8253A interrupt time > if(flag==Up_Completed) > { > ud->set_status(Completed); > Dar_forb_flag=1; > } > if(max_count<=distance) > {// cout<<"\nnow down"< ud->set_status(Down_Status);Dar_forb_flag=0;} > > overflow_flag_x=0; > overflow_flag_y=0; > overflow_flag_z=0; > if(X_COUNT!=0) > { sum_integrator_x+=integrator_x; > if(sum_integrator_x>=Constant) > { sum_integrator_x-=Constant; > overflow_flag_x=1; > X_AXIE++; > X_COUNT--; > dr->insert_to_output(X_Axes,Plus_Direction); > X_derect=1; > } > if(sum_integrator_x<=-Constant) > { sum_integrator_x+=Constant; > overflow_flag_x=1; > X_AXIE--; > X_COUNT++; > dr->insert_to_output(X_Axes,Minus_Direction); > X_derect=-1; > } > } > if(Y_COUNT!=0) > { if(sum_integrator_y>=Constant) > { sum_integrator_y-=Constant; > overflow_flag_y=1; > Y_AXIE++; > Y_COUNT--; > dr->insert_to_output(Y_Axes,Plus_Direction); > Y_derect=1; > } > if(sum_integrator_y<=-Constant) > { sum_integrator_y+=Constant; > overflow_flag_y=1; > Y_AXIE--; > Y_COUNT++; > dr->insert_to_output(Y_Axes,Minus_Direction); > Y_derect=-1; > } > } > if(Z_COUNT!=0) > { sum_integrator_z+=integrator_z; > if(sum_integrator_z>=Constant) > { sum_integrator_z-=Constant; > overflow_flag_z=1; > Z_AXIE++; > Z_COUNT--; > dr->insert_to_output(Z_Axes,Plus_Direction); > Z_derect=1; > } > if(sum_integrator_z<=-Constant) > { sum_integrator_z+=Constant; > overflow_flag_z=1; > Z_AXIE--; > Z_COUNT++; > dr->insert_to_output(Z_Axes,Minus_Direction); > Z_derect=-1; > } > } > switch(PLANE1_FLAG) > { > case 1: > if(overflow_flag_x)integrator_y+=wayflag; > if(overflow_flag_y)integrator_x+=(-wayflag); > break; > case 2: > if(overflow_flag_x)integrator_z+=(-wayflag); > if(overflow_flag_x)integrator_x+=wayflag; > break; > case 3: > if(overflow_flag_y)integrator_z+=wayflag; > if(overflow_flag_z)integrator_y+=(-wayflag); > break; > } > if(X_COUNT==0&&Y_COUNT==0&&Z_COUNT==0) > ALL_END=1; > > dr->output(); > } > I use the method DDA to realize drawing a circle. > the main trouble I think is the fuction itself,not relative to > others.Could you do me a favor and point to the flaws and corrent > it.thank you very much. > My email is zhangjianke629@hotmail.com OR > zhangjianke629@yahoo.com.cn .