1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
4 /** a line segment defined by two points in space */
5 public class Segment implements HasBoundingBox {
10 public Segment(Point p1, Point p2) { this.p1 = p1; this.p2 = p2; }
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;
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); }