blob: 638a4696db04663912d1064a599bf742528e5ba9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*************************************************************************
* Compilation: javac KdTreeVisualizer.java
* Execution: java KdTreeVisualizer
* Dependencies: StdDraw.java Point2D.java KdTree.java
*
* Add the points that the user clicks in the standard draw window
* to a kd-tree and draw the resulting kd-tree.
*
*************************************************************************/
public class KdTreeVisualizer {
public static void main(String[] args) {
StdDraw.show(0);
KdTree kdtree = new KdTree();
while (true) {
if (StdDraw.mousePressed()) {
double x = StdDraw.mouseX();
double y = StdDraw.mouseY();
System.out.printf("%8.6f %8.6f\n", x, y);
Point2D p = new Point2D(x, y);
kdtree.insert(p);
StdDraw.clear();
kdtree.draw();
}
StdDraw.show(50);
}
}
}
|