How to hand in your solution: please email me a "jar file" containing the following files:
In this homework, we want you to program in Java to implement a simple algorithm to compute the pairwise intersections of a set of line segments. We will proceed in stages.
SegIntersect.javawhich, reads a list of line segments from a file and computes all their intersections using naive quadratic time algorithm. For output, print a list of the pairs of intersecting segments, and their intersection points, to an output file.
SEG
x1 , y1, x2 , y2
where SEG
is a keyword, and (x1,y1) and (x2,y2)
are the integer coordinates of the endpoints of the segment.
The commas are mandatory.
If you want highly readable version of this, you
could have
SEG
\
x1 , y1 , \ # first endpoint
x2 , y2 # second endpoint
EOF
.
GuiSegIntersect.javawhich couples the program from STEP 1 to a GUI interface. We want the user to specify input segments by clicking end points. There are radio buttons called "Mouse Input", "File Input", "Graphical Output" and "File Output". When the "Mouse Input" button is depressed, you clear the screen and start reading the mouse clicks to define segments. When the "Graphical Output" button is depressed, you compute the intersections and display the segments AND mark all intersections with small circles. The file input and output radio buttons are obvious, but you need to read in a file name.
SweepSegIntersect.java
.
In this case, we want to
re-do STEP 1 but using the line-sweep algorithm discussed
in class (and in the text). Perform some timings to
compare your two programs.
In order to do this, you will need to implement two different kinds of balanced binary trees. I am just as happy to have you take code from ANY legal source (as long as you acknowledge this).
If you want to implement your own, there are many choices, but I recommend the use of Splay Trees. I can give you more information on how to do this quite simply if you talk to me.