Esempio n. 1
0
  // The intersection of line not plane
  // same with segment intersection
  private GeomObj2 baseIntersectPlane(Line that) {
    CohoNumber A1 = A(); // Ax+By=C
    CohoNumber B1 = B();
    CohoNumber C1 = C();

    CohoNumber A2 = that.A();
    CohoNumber B2 = that.B();
    CohoNumber C2 = that.C();

    CohoNumber denom = A1.mult(B2).sub(B1.mult(A2));
    //		System.out.println(denom);
    //		System.out.println(A1.sub(A2).doubleValue());
    //		System.out.println(A1.doubleValue()-(A2.doubleValue()));
    CohoNumber num1 = B1.mult(C2).sub(B2.mult(C1));
    CohoNumber num2 = C1.mult(A2).sub(C2.mult(A1));
    if (denom.compareTo(denom.zero()) == 0) {
      if (num1.compareTo(num1.zero()) != 0 || num2.compareTo(num2.zero()) != 0) { // no intersection
        return Empty.instance();
      } else { // intersection is segment
        return this; // same line
      }
    } else {
      Point pt = Point.create(num1.div(denom), num2.div(denom));
      // System.out.println(pt+""+type);
      return pt;
    }
  }