5f460517d92c54a90f4bfffc55592fe77ad601dc
[anneal.git] / src / edu / berkeley / qfat / geom / Segment.java
1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
3
4 /** a line segment defined by two points in space */
5 public class Segment implements HasBoundingBox {
6
7     public final Point p1;
8     public final Point p2;
9
10     public Segment(Point p1, Point p2) { this.p1 = p1; this.p2 = p2; }
11
12     public int hashCode() { return p1.hashCode() ^ p2.hashCode(); }
13     public boolean equals(Object o) {
14         if (o==null || !(o instanceof Segment)) return false;
15         Segment seg = (Segment)o;
16         if (seg.p1.equals(p1) && seg.p2.equals(p2)) return true;
17         if (seg.p2.equals(p1) && seg.p1.equals(p2)) return true;
18         return false;
19     }
20
21     public float getMaxX() { return Math.max(p1.x, p2.x); }
22     public float getMinX() { return Math.min(p1.x, p2.x); }
23     public float getMaxY() { return Math.max(p1.y, p2.y); }
24     public float getMinY() { return Math.min(p1.y, p2.y); }
25     public float getMaxZ() { return Math.max(p1.z, p2.z); }
26     public float getMinZ() { return Math.min(p1.z, p2.z); }
27
28     public double distance(Point p) {
29         throw new RuntimeException("not yet implemented");
30     }
31
32 }