AngleRaysSeg Documentation
The code presented in AngleRaysSeg.cpp is used to generate a postscript file with a drawing of a set of circles reflecting off a given set of segments. The input file contains the number of segments, the coordinates of their endpoints, the number of rays, the coordinates of the source of light, the start angle and the cone spread angle, in degrees. In order to shoot just one ray at a certain angle, one can input "1" for the number of rays, and use the start angle to direction the ray.
Input:
Executing the program
The Makefile:
#-----------------------------------------
AngleRaysSeg: AngleRaysSeg.oTo run:
% AngleRaysSeg < file.input > output.ps
Alternately, one does not have to run the program with an input file but it is necessary that an output postscript file be specified in order to view the saved image. Otherwise, the data is simply output to the screen and not saved.
There is also the option to run the program with debugging output. To do so:
% AngleRaysSeg [d] [D] < file.input > output.ps
Sample input file:
This input file will draw four segments in the shape of a square with 5 point gaps at each end. A light source will be generated in the center of the square emitting three rays over a span of ninety degrees, each ray thirty degrees apart. The light rays will bounce only once so that it is clear how the program manipulates the input.
Input file (file.input)
4
Output Postscript File (output.ps)
%!PS
The Postscript Image (output.ps)
Example Image 2 - Same scenario with ten bounces (shows light rays escaping mirror trap)
Example Image Three - Five Randomly Generated Segments
In this example
SegGen was used to create an output file containing the coordinates of five randomly generated segments. We modified SegGen's output file so that its format would be compatible with AngleRaysSeg's input format. We chose the coordinates of the light source, the angular spread, ten bounces, and then ran AngleRaysSeg with the modified output file.SegGen Input file
5
SegGen Output file
Desired number of segments?AngleRaysSeg Result