public static Coordinate getIntersection(Coordinate p00, Coordinate p01, Coordinate p10, Coordinate p11) { CentralEndpointIntersector intor = new CentralEndpointIntersector(p00, p01, p10, p11); return intor.getIntersection(); }
private void compute() { Coordinate centroid = average(pts); intPt = new Coordinate(findNearestPoint(centroid, pts)); }
public CentralEndpointIntersector(Coordinate p00, Coordinate p01, Coordinate p10, Coordinate p11) { pts = new Coordinate[] { p00, p01, p10, p11 }; compute(); }
/** * Computes a segment intersection using homogeneous coordinates. * Round-off error can cause the raw computation to fail, * (usually due to the segments being approximately parallel). * If this happens, a reasonable approximation is computed instead. * * @param p1 a segment endpoint * @param p2 a segment endpoint * @param q1 a segment endpoint * @param q2 a segment endpoint * @return the computed intersection point */ private Coordinate safeHCoordinateIntersection(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2) { Coordinate intPt = null; try { intPt = HCoordinate.intersection(p1, p2, q1, q2); } catch (NotRepresentableException e) { // System.out.println("Not calculable: " + this); // compute an approximate result intPt = CentralEndpointIntersector.getIntersection(p1, p2, q1, q2); // System.out.println("Snapped to " + intPt); } return intPt; }
intPt = CentralEndpointIntersector.getIntersection(p1, p2, q1, q2);
public static Coordinate getIntersection(Coordinate p00, Coordinate p01, Coordinate p10, Coordinate p11) { CentralEndpointIntersector intor = new CentralEndpointIntersector(p00, p01, p10, p11); return intor.getIntersection(); }
private void Ocompute() { Coordinate centroid = average(pts); intPt = new Coordinate(findNearestPoint(centroid, pts)); }
public CentralEndpointIntersector(Coordinate p00, Coordinate p01, Coordinate p10, Coordinate p11) { pts = new Coordinate[] { p00, p01, p10, p11 }; compute(); }