SegGen Documentation

The code presented in SegGen.cpp is used to generate a disjoint set of random segments. The input file only needs the desired number of segments. The output file contains the number of segments and the respective coordinates, followed by the input format for the segment-ray intersection code-- the coordinates of a randomly generated ray, separated by a 1 from the rest of the coordinates. The output file needs further processing in order to be accepted as input for the segment-ray code (ie. there are text outputs that need to be removed). Also, if the generator cannot create a valid non-intersecting segment after a certain number of tries, it prints an error message on the corresponding line.


The number of segments one wishes to generate (int)

Executing the program

The Makefile


SegGen: SegGen.o

g++ -o SegGen SegGen.o

SegGen.o: SegGen.cpp

g++ -c SegGen.cpp



rm SegGen.o SegGen


To run:

% SegGen < file.input > file.output

Alternatively, SegGen can run without an input file, but an output file must be selected or the data will be lost as it is simply output to the screen.

Sample input file:

This input file will generate five random segments.

Input file (file.input)


Output file (file.output)

Desired number of segments?


451 30 480 279

168 445 225 293

326 163 53 294

402 13 162 153

209 385 426 149

213 133


126 213



Explanation of output data:

Desired number of segments? ß must be deleted

5 ß number of segments

451 30 480 279 ß segment's start/end xy coordinates

168 445 225 293

326 163 53 294

402 13 162 153

209 385 426 149

213 133ß randomly generated xy coordinates for the light's source

1ß number of rays generated (always one)

126 213ß randomly generated angular spread (the angle by which each ray should be separated from the next, and the angle that is the maximum spread of all emitted light rays)

Bounces: ß must be deleted

5 ß the number of times the light ray should bounce (always five - can be reset)

Return to main page