/* *** example to draw the interference pattern of light falling on a grid with n slits and ratio r of slit width over distance between slits ****/ /* func t i on code in C */ double single(double *x,double *par) { double const pi=4*atan ( 1 . ); return pow(sin(pi*par[0]*x[0])/(pi*par[0]*x[0]),2); } double nslit0(double *x,double *par) { double const pi=4*atan(1.); return pow(sin(pi*par[1]*x[0])/sin(pi*x[0]),2); } double nslit(double *x ,double *par) { return single(x,par)*nslit0(x,par); } /* This is the main program */ void slits() { float r,ns; /* request user input */ cout << "slit width / g ? " ; scanf ("%f",&r); cout << "# of slits? " ; scanf ("%f",&ns); cout <<"interference pattern for "<< ns<<" slits , width/distance: "<SetNpx (500) ; // set number of point s to 500 Fnslit->SetParameter (0,r); // set parameters, as read in above Fnslit->SetParameter (1,ns); Fnslit->Draw(); // draw the interference pattern for a grid with n slits }