Beispiel #1
0
 /**
  * Common implementation for the search operations.
  *
  * @param pt
  * @param safe
  * @return
  * @throws DelaunayError
  */
 private Element searchPointImpl(final DPoint pt, final boolean safe) throws DelaunayError {
   Element ret = null;
   if (contains(pt)) {
     return this;
   } else {
     for (DEdge ed : edges) {
       DPoint op = getOppositePoint(ed);
       if (ed.isRight(pt) && ed.isLeft(op)) {
         if (ed.isLocked() && safe) {
           return null;
         } else if (ed.getRight() != null) {
           return ed.getRight().searchPointContainer(pt);
         } else {
           ret = ed;
         }
       } else if (ed.isLeft(pt) && ed.isRight(op)) {
         if (ed.isLocked() && safe) {
           return null;
         } else if (ed.getLeft() != null) {
           return ed.getLeft().searchPointContainer(pt);
         } else {
           ret = ed;
         }
       }
     }
   }
   return ret;
 }
Beispiel #2
0
  /**
   * Check if the point is inside the triangle
   *
   * @param aPoint
   * @return isInside
   */
  public final boolean isInside(DPoint aPoint) {
    boolean isInside = true;

    int k = 0;
    while ((k < PT_NB) && (isInside)) {
      DEdge theEdge = edges[k];

      if (theEdge.getLeft() == this) {
        if (theEdge.isRight(aPoint)) {
          isInside = false;
        }
      } else {
        if (theEdge.isLeft(aPoint)) {
          isInside = false;
        }
      }
      k++;
    }
    return isInside;
  }