X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2Fgeom%2FSegment.java;h=576bb7546245f52e7e2a6e7e164987c97fa94391;hp=8a1febd7010271e18e85762d1a248d2d36c84836;hb=4c6451ef747ae7ffc2aa8955e55254673ac49d16;hpb=db91e356d433030537508cacbf91bce9dd82f38f diff --git a/src/edu/berkeley/qfat/geom/Segment.java b/src/edu/berkeley/qfat/geom/Segment.java index 8a1febd..576bb75 100644 --- a/src/edu/berkeley/qfat/geom/Segment.java +++ b/src/edu/berkeley/qfat/geom/Segment.java @@ -9,6 +9,15 @@ public class Segment implements HasBoundingBox { public Segment(Point p1, Point p2) { this.p1 = p1; this.p2 = p2; } + public int hashCode() { return p1.hashCode() ^ p2.hashCode(); } + public boolean equals(Object o) { + if (o==null || !(o instanceof Segment)) return false; + Segment seg = (Segment)o; + if (seg.p1.equals(p1) && seg.p2.equals(p2)) return true; + if (seg.p2.equals(p1) && seg.p1.equals(p2)) return true; + return false; + } + public float getMaxX() { return Math.max(p1.x, p2.x); } public float getMinX() { return Math.min(p1.x, p2.x); } public float getMaxY() { return Math.max(p1.y, p2.y); }