#include #include #include #define MAXR 300 #define MAXTHETA 360 /* cc -o lookat lookat.c -lm lookat KIWA.vol140.dat This little gem of a program reads in KIWA.vol140.dat and demonstrates how to convert an (x,y) coordinate to an (r,theta) coordinate, and to then grab the data value from val(r,theta). The students task is to convert this program to one that outputs a .ppm image file of the radar data. */ main(int argc, char *argv[]) { FILE *ifp,*ofp; float val[MAXR][MAXTHETA]; float x,y,r,th,pi,rad,v; char firstline[200]; int i,j,red,green,blue,ri,thi; pi=4*atan2(1.,1.); rad=180./pi; printf("will try to read %s\n",argv[1]); ifp=fopen(argv[1],"r"); fgets(firstline,200,ifp); for (ri=0; ri255) || (blue>255) || (green>255)) { printf("Value exceeds max"); } fprintf(ofp,"%d %d %d\n",red,green,blue); } } }