#include #include #include #include #include #include "struct.h" #define DING ping #define MAX_NULL 2000 #define MAXODE 50 extern GRAPH *MyGraph; extern Display *display; extern (*rhs)(); extern double last_ic[MAXODE]; extern double DELTA_T,TEND,TRANS; extern int PaperWhite,DCURY; extern Window main_win; int NULL_HERE,num_x_n,num_y_n,num_index, null_ix,null_iy,WHICH_CRV; float null_dist,*X_n,*Y_n,*saver,*NTop,*NBot; extern int NMESH,NODE,NJMP,NMarkov,FIX_VAR; float fnull(); typedef struct { float x,y,z; } Pt; /* all the nifty 2D stuff here */ direct_field() { static char *n[]={"(D)irect Field","(F)low"}; static char key[]="df"; char ch; int i,j,start,k; int inx=MyGraph->xv[0]-1; int iny=MyGraph->yv[0]-1; double y[MAXODE],ydot[MAXODE],xv1,xv2; float v1[MAXODE],v2[MAXODE]; double amp; double t; double du,dv,u0,v0; double oldtrans=TRANS; Window temp=main_win; int grid=10; if(MyGraph->TimeFlag||MyGraph->xv[0]==MyGraph->yv[0]||MyGraph->ThreeDFlag) return; ch=(char)pop_up_list(&temp,"Two-D Fun",n,key,2,12,0,10,6*DCURY+8); if(ch==27)return; new_int("Grid:",&grid); if(grid<=1)return; du=(MyGraph->xhi-MyGraph->xlo)/(double)grid; dv=(MyGraph->yhi-MyGraph->ylo)/(double)grid; u0=MyGraph->xlo; v0=MyGraph->ylo; set_color(MyGraph->color[0]); if(ch!='f'){ get_ic(2,y); for(i=0;i<=grid;i++){ y[inx]=u0+du*i; for(j=0;j<=grid;j++){ y[iny]=v0+dv*j; rhs(0.0,y,ydot,NODE); if(MyGraph->ColorFlag){ for(k=0;kxv[0]==null_ix&&MyGraph->yv[0]==null_iy&&MyGraph->ThreeDFlag==0) { /* set_color(col1); */ restor_null(X_n,num_x_n); /* set_color(col2); */ restor_null(Y_n,num_y_n); } } restor_null(v,n) float *v; int n; { int i,i4; for(i=0;iThreeDFlag||MyGraph->TimeFlag||MyGraph->xv[0]==MyGraph->yv[0])return; ch=(char)pop_up_list(&temp,"Nullclines",n,key,4,10,0,10,6*DCURY+8); if(ch=='r'){ restore_nullclines(); return; } if(ch=='a'){ MyGraph->Nullrestore=1; return; } if(ch=='m'){ MyGraph->Nullrestore=0; return; } if(ch=='n'){ for(i=NODE;ixmin; xmax=(float)MyGraph->xmax; y_tp=(float)MyGraph->ymax; y_bot=(float)MyGraph->ymin; null_ix=MyGraph->xv[0]; null_iy=MyGraph->yv[0]; if(NULL_HERE==0) { if((X_n=(float *)malloc(4*MAX_NULL*sizeof(float)))!=NULL && (Y_n=(float *)malloc(4*MAX_NULL*sizeof(float)))!=NULL) NULL_HERE=1; NTop=(float *)malloc((course+1)*sizeof(float)); NBot=(float *)malloc((course+1)*sizeof(float)); if(NTop==NULL||NBot==NULL)NULL_HERE=0; } else { free(NTop); free(NBot); NTop=(float *)malloc((course+1)*sizeof(float)); NBot=(float *)malloc((course+1)*sizeof(float)); if(NTop==NULL||NBot==NULL){NULL_HERE=0; return;} } num_index=0; saver=X_n; WHICH_CRV=null_ix; /* set_color(col1); */ do_cline(course,xmin,y_bot,xmax,y_tp); ping(); num_x_n=num_index; num_index=0; saver=Y_n; WHICH_CRV=null_iy; /* set_color(col2); */ do_cline(course,xmin,y_bot,xmax,y_tp); num_y_n=num_index; ping(); } } stor_null(x1,y1,x2,y2) float x1,y1,x2,y2; { int i; if(num_index>MAX_NULL)return; i=4*num_index; saver[i]=x1; saver[i+1]=y1; saver[i+2]=x2; saver[i+3]=y2; num_index++; } float fnull( x, y) float x,y; { double y1[MAXODE],ydot[MAXODE]; int i; for(i=0;i=p2.z))|| ((0.0>=p1.z)&&(0.0<=p2.z))) */ if(interpolate(p1,p2,0.0,&x[count],&y[count]))count++; if( p1.z*p3.z<=0.0) /* if(((0.0<=p1.z)&&(0.0>=p3.z))|| ((0.0>=p1.z)&&(0.0<=p3.z))) */ if(interpolate(p1,p3,0.0,&x[count],&y[count]))count++; if(p2.z*p3.z<=0.0) /* if(((0.0<=p3.z)&&(0.0>=p2.z))|| ((0.0>=p3.z)&&(0.0<=p2.z))) */ if(interpolate(p3,p2,0.0,&x[count],&y[count]))count++; if(count==2){ line_abs(x[0],y[0],x[1],y[1]); stor_null(x[0],y[0],x[1],y[1]); } } do_cline(ngrid,x1,y1,x2,y2) int ngrid; float x1,y1,x2,y2; { float dx=(x2-x1)/(float)ngrid; float dy=(y2-y1)/(float)ngrid; float x,y,z; Pt p[5]; char esc; int i,j,cwidth; int nx=ngrid+1; int ny=ngrid+1; cwidth=get_command_width(); y=y2; for(i=0;i