Exemplo n.º 1
0
 /**
  * Determines the orientation of a LineSegment relative to this segment. The concept of
  * orientation is specified as follows: Given two line segments A and L,
  *
  * <ul
  * <li>
  *   A is to the left of a segment L if A lies wholly in the closed half-plane lying to the left
  *   of L
  *   <li>A is to the right of a segment L if A lies wholly in the closed half-plane lying to the
  *       right of L
  *   <li>otherwise, A has indeterminate orientation relative to L. This happens if A is collinear
  *       with L or if A crosses the line determined by L.
  * </ul>
  *
  * @param seg the LineSegment to compare
  * @return 1 if <code>seg</code> is to the left of this segment
  * @return -1 if <code>seg</code> is to the right of this segment
  * @return 0 if <code>seg</code> is collinear to or crosses this segment
  */
 public int orientationIndex(LineSegment seg) {
   int orient0 = CGAlgorithms.orientationIndex(p0, p1, seg.p0);
   int orient1 = CGAlgorithms.orientationIndex(p0, p1, seg.p1);
   // this handles the case where the points are L or collinear
   if (orient0 >= 0 && orient1 >= 0) return Math.max(orient0, orient1);
   // this handles the case where the points are R or collinear
   if (orient0 <= 0 && orient1 <= 0) return Math.max(orient0, orient1);
   // points lie on opposite sides ==> indeterminate orientation
   return 0;
 }
Exemplo n.º 2
0
 /**
  * Determines the orientation index of a {@link Coordinate} relative to this segment. The
  * orientation index is as defined in {@link CGAlgorithms#computeOrientation}.
  *
  * @param p the coordinate to compare
  * @return 1 (LEFT) if <code>p</code> is to the left of this segment
  * @return -1 (RIGHT) if <code>p</code> is to the right of this segment
  * @return 0 (COLLINEAR) if <code>p</code> is collinear with this segment
  * @see CGAlgorithms#computeOrientation(Coordinate, Coordinate, Coordinate)
  */
 public int orientationIndex(Coordinate p) {
   return CGAlgorithms.orientationIndex(p0, p1, p);
 }