Computer Science 102 Short Program 1 Due 26 January 11:59PM For this program the ONLY authorized source of assistance is Dr. Westall or the TA's. ANY OTHER DISCUSSION of the program no matter how "high level" or "peripheral" (e.g. Have you started/finished it yet?) is STRICTLY FORBIDDEN. Any student who observes improper behavior is encouraged to report it to Dr. Westall. Reports that can be verified will be rewarded with a 20 point bonus on the assignment for the student doing the reporting and an F for the course for the student being reported!! Adhere to the following programming standards. Violations will lead to deductions. (1) no function should be longer than 30 lines code + whitespace. (2) the maximum nesting level in any function is ONE (3) code lines should not extend beyond column 72 (4) no more that one statement may be written on a single line (5) use reasonably descriptive names for variables and functions (6) package all functions into a single source code module named camera.c (7) your program should compile without any warnings with gcc -Wall (8) indenting should be consistent with logical nesting (9) diagnostic / debug prints should be disabled/deleted in your submission. Your mission in this assignment is to complete three functions that belong to the camera.c file. Begin by copying all the files in /home/westall/class/102/assns/sp1 to your own sp1 directory. After that copy your own vector.h to that directory. Now read the file main1.c. This contains the main function for your program. You will see that it calls three functions that will live in the camera.c module. cam = cam_init(stdin); assert(cam != NULL); cam_dump(stderr, cam); int x, y; vec_t dir; char buf[20]; while (fscanf(stdin, "%d %d", &x, &y) == 2) { cam_getdir(cam, x, y, &dir); sprintf(buf, "pix (%3d, %3d) - ", x, y); vec_prn(stderr, buf, &dir); } These functions should operate as follows: cam_init() malloc a cam_t structure parse the camera definition (SAMPLE input is main1.txt) but remember camera attributes may occur in ANY order store the input values in the cam_t structure make sure your parser aborts on invalid input malloc space for the pixmap and store its address in the cam_t return the address of the cam_t cam_dump() printout the camera data in the format shown in main1.out cam_getdir(cam_t *cam, int x, int y, vec_t *dir) the vector pointed to by dir should be filled in with a unit vector pointing from the viewpoint to the pixel with coordinates (x, y) Use the world_x = world_size_x * win_x / (win_size_x - 1) formulation in the computation. <<>> You must turn in ALL the files needed to build your program: camera.c main1.c rayfuns.h ray.h rayhdrs.h vector.h Your program should compile correctly when I (or you) enter the command: gcc -g -Wall *.c -lm It should not generate any warning messages HOW TO SUBMIT YOUR CODE: NOTE: This procedure has NOTHING in common with "handin" nor "sendlab" Do NOT even TRY to think about how they fit into this procedure because THEY DON'T!! 1. From any departmental Solaris system ssh to workstation jmw 2. The submission directories lie in the directory /local/jmw2/102/sp1 which is available ONLY IF YOU HAVE LOGGED INTO WORKSTATION jmw. Each student has a subdirectory of /local/jmw2/102/sp1. The name of your subdirectory is your userid (in the example we will assume your id is wjsmith). 3. copy (via the cp command) required file to your subdirectory in /local/jmw2/102 /sp1 For example: cp /home/wjsmith/102/sp1/camera.c /local/jmw2/102/sp1/wjsmith Here you would obviously need to replace /home/wjsmith/102/sp1/flag.c with wherever you have your the program you are trying to submit. 4. Don't modify the permissions on your subdirectory. They are set so that ONLY you can access your directory. ---------------- After you think you have turned your programs in, its a good idea to cd /local/jmw2/102/sp1/wjsmith and make sure your files are there and they still compile and work correctly.