
The third test run for the program was done using the parameters [Ps,Qs,z0] = [0,1,35]. With a positive value for Qs, the light source is pointing downward onto the sphere. The visible cap of the sphere will be towards the top of the sphere as it is viewed in our image. The output image for this test run is shown in Figure 3.
The next test run for the program was done using the parameters [Ps,Qs,z0] = [1,1,35]. With positive values for Ps and Qs, the light source is above the sphere and to the right of its center. The visible cap of the sphere will be towards the top of the sphere, but the intensity center of the cap will be to the right of the sphere's center. The output image for this test run is shown in Figure 4.
More test runs with similar parameters were done to verify the correctness of our program. The output images for those runs can be seen in Figure 5 and Figure 6. The parameters that were used are shown in the captions.
Another test run was done using the parameters [Ps,Qs,z0] = [1000,0,45]. The huge positive value for Ps indicates that the light source is far to the right of the sphere. It is so far to the right, that it appears as if it is pointing directly left onto the sphere. Thus, the visible cap will be on the right side of the sphere, and we will only be able to see half of the cap. The increased value for z0 also means the sphere is further away from the camera and will appear to be smaller. The output image for this test run is shown in Figure 7.
The final test run was done using the paramters [Ps,Qs,z0] = [0,1000,45]. The output image is similar to that of the previous test run except the visible cap is now on the top of the sphere. This image is shown in Figure 8.
Here is a sample text output from executing the program:
------------------------------------------------------------------------------ Radius of sphere = 4 Focal length of camera lens = 5 Range of image plane = [-1,1]x[-1,1] ------------------------------------------------------------------------------ p_s = 0 q_s = 0 z0 = 30 Direction of point source = [-0,-0,1] = [-0.000,-0.000,1.000] ------------------------------------------------------------------------------ Radius of sphere on image plane = 0.810441 Number of points sampled for image plane = 415x415 = 172225 Generating shading information..... 100% Completed! Consumed 6.0 seconds. ------------------------------------------------------------------------------ Writing 256x256 image to file "/tmp/sphere.ppm"...done! ------------------------------------------------------------------------------
The file matrix.h is the header file for
the class of functions for matrix operations (C++).
The file matrix.cc is the
implementation file for the class of functions for matrix operations (C++).
The file image.h is the header file for
the class of functions for image manipulation (C++).
The file image.cc is the implementation
file for the class of functions for image manipulation (C++).
The file main.cc is the main driving routine for this project (C++).
Note: Special run scripts are necessary to execute the code.
For a complete copy of the code, scripts, and objects, click here.
After you have downloaded the file:
Binary for SunOS: proj4sunOS
All images are 256 x 256.
Figure 1: [Ps,Qs,z0] = [0,0,30]
Figure 2: [Ps,Qs,z0] = [0,0,20]
Figure 3: [Ps,Qs,z0] = [0,1,35]
Figure 4: [Ps,Qs,z0] = [1,1,35]
Figure 5: [Ps,Qs,z0] = [0.2,0.4,30]
Figure 6: [Ps,Qs,z0] = [3,2,30]
Figure 7: [Ps,Qs,z0] = [1000,0,45]
Figure 8: [Ps,Qs,z0] = [0,1000,45]
Source code:
gunzip -c project4.tar.gz | tar -xvf -"
./run [Ps] [Qs] [z0]" to execute the code
Binary:
Binary for Linux: proj4linux