コード例 #1
0
 /**
  * Computes the (approximate) intersection point between two line segments using homogeneous
  * coordinates.
  *
  * <p>Note that this algorithm is not numerically stable; i.e. it can produce intersection points
  * which lie outside the envelope of the line segments themselves. In order to increase the
  * precision of the calculation input points should be normalized before passing them to this
  * routine.
  */
 public static Coordinate intersection(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
     throws NotRepresentableException {
   HCoordinate l1 = new HCoordinate(new HCoordinate(p1), new HCoordinate(p2));
   HCoordinate l2 = new HCoordinate(new HCoordinate(q1), new HCoordinate(q2));
   HCoordinate intHCoord = new HCoordinate(l1, l2);
   Coordinate intPt = intHCoord.getCoordinate();
   return intPt;
 }