|
|
1.1 ! root 1: /* From alice!doyle Fri Feb 1 17:19 EST 1985 */ ! 2: /* modified slightly by ehg */ ! 3: /* based on mvefil.f by rksmith */ ! 4: #include <stdio.h> ! 5: #include <math.h> ! 6: #include "view2d.h" ! 7: ! 8: #define max(a,b) (a<b ? b : a) ! 9: #define min(a,b) (a>b ? b : a) ! 10: #define abs(x) (x>=0 ? x : -(x)) ! 11: #define inf 1.e30 ! 12: ! 13: moviefil(fd, nx, ny, time, outside, fa) ! 14: int fd, nx, ny; ! 15: float time, outside, fa[]; ! 16: { ! 17: int i; ! 18: int npts; ! 19: float f, v2; ! 20: short u, v; ! 21: float fmin, fmax, grange, gmax, gmin; ! 22: double tim; ! 23: short *data, *d; ! 24: char *malloc(); ! 25: ! 26: tim = time; ! 27: npts = nx*ny; ! 28: data = (short *)malloc((unsigned)npts*sizeof(short)); ! 29: if(data==NULL){fprintf(stderr,"out of memory!\n");exit(9);} ! 30: ! 31: fmin = inf; ! 32: fmax = -inf; ! 33: for (i=0;i<npts;i++) { ! 34: if(fa[i]>outside){ ! 35: fmin = min(fa[i], fmin); ! 36: fmax = max(fa[i], fmax); ! 37: } ! 38: } ! 39: ! 40: gmax = (fmax<0)?0:fmax; ! 41: gmin = (fmin>0)?0:fmin; ! 42: grange = gmax - gmin; ! 43: if(grange<=0){ v = 0; u=0; } ! 44: else{ ! 45: f = 2*BIG-2; ! 46: v = log(grange)/log(2.)-14; ! 47: v2 = pow(2.,(double)v); ! 48: while( 2*grange < f*v2 ){ v--; v2 /= 2; } ! 49: f = -(gmin+gmax)/(2*v2); ! 50: u = f; ! 51: if( (f<-BIG)||(f>BIG) ){ ! 52: fprintf(stderr,"fmin=%g fmax=%g u=%d v=%d\n",fmin,fmax,u,v); ! 53: fprintf(stderr,"u out of bounds f=%g",f); ! 54: exit(1); ! 55: } ! 56: } ! 57: ! 58: for(d = data, i = 0; i < npts; i++, d++){ ! 59: if(fa[i]<=outside){ ! 60: *d = -BIG-1; /* out of bounds */ ! 61: }else{ ! 62: *d = u + fa[i]/v2; ! 63: } ! 64: } ! 65: view2d(fd,nx,ny,tim,u,v,0,0,0,data); ! 66: free((char *)data); ! 67: } ! 68: ! 69: ! 70: fmovie_(nx,ny,time,outside,f) ! 71: int *nx, *ny; ! 72: float *time, *outside, *f; ! 73: { ! 74: moviefil(1,*nx,*ny,*time,*outside,f); ! 75: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.