Beispiel #1
0
  // for interval lp-project
  public boolean similar(Line p) {
    double theta = Math.atan2(B.doubleValue(), A.doubleValue());
    double angle = theta >= 0 ? theta : 2 * Math.PI + theta;
    double ptheta = Math.atan2(p.B.doubleValue(), p.A.doubleValue());
    double pangle = ptheta >= 0 ? ptheta : 2 * Math.PI + ptheta;

    double norm = Math.sqrt(A.mult(A).add(B.mult(B)).doubleValue());
    double pnorm = Math.sqrt(p.A.mult(p.A).add(p.B.mult(p.B)).doubleValue());

    return (Math.abs(angle - pangle) < eps)
        && (Math.abs(C.doubleValue() / norm - p.C.doubleValue() / pnorm) < eps);
  }