import java.awt.*; class HalfSpace { public double a, b, c; public Segment s; public HalfSpace(Segment s, double a, double b, double c) { this.s = s; this.a = a; this.b = b; this.c = c; } public void draw(Graphics g, Color clr) { return; // FIXME: figure out how to draw this later } public boolean inPosPlane(Node n) { boolean result = a*n.x + b*n.y + c > 0; // System.out.println("inPosPlane: "+n+" "+result); return result; } public Node intersect(HalfSpace hs) { double det = a*hs.b - b*hs.a; Util.assert(Math.abs(det) > 0.0001, "HalfSpace::intersect() "+this+" "+hs); double x = (b*hs.c - hs.b*c)/det; double y = (c*hs.a - a*hs.c)/det; return new Node((int)Math.round(x), (int)Math.round(y)); } public String toString() { return "HS["+a+","+b+","+c+"]"; } }