Ejemplo n.º 1
0
  /**
   * Returns true if the triangle is turned toward the edge ed.
   *
   * @param ed
   * @return true if this is pouring into ed.
   * @throws org.jdelaunay.delaunay.error.DelaunayError
   */
  public final boolean isTopoOrientedToEdge(DEdge ed) throws DelaunayError {
    // on determine les sommets A,B et C du triangle et on calle AB (ou BA)
    // sur e
    DPoint a = ed.getStartPoint();
    DPoint b = ed.getEndPoint();
    if (!this.belongsTo(a) || !belongsTo(b)) {
      throw new DelaunayError(DelaunayError.DELAUNAY_ERROR_OUTSIDE_TRIANGLE);
    }

    DPoint c = getOppositePoint(ed);
    DPoint ab = Tools.vectorialDiff(b, a);
    DPoint ac = Tools.vectorialDiff(c, a);
    // orientation CCW
    if (Tools.vectorProduct(ab, ac).getZ() < 0) {
      // echange A et B
      DPoint d = a;
      a = b;
      b = d;
      ab = Tools.vectorialDiff(b, a);
    }
    // test d'intersection entre AB et P
    DPoint p = getSteepestVector();
    return Tools.vectorProduct(ab, p).getZ() < 0;
  }
Ejemplo n.º 2
0
 /**
  * Compute the intersection point according the steepest vector. We assume that the point is in
  * the Triangle
  *
  * @param dPoint
  * @return DPoint
  * @throws DelaunayError
  */
 public final DPoint getSteepestIntersectionPoint(DPoint dPoint) throws DelaunayError {
   if (isInside(dPoint)) {
     for (DEdge dEdge : edges) {
       if (isTopoOrientedToEdge(dEdge)) {
         DPoint pt =
             Tools.computeIntersection(
                 dEdge.getStartPoint(), dEdge.getDirectionVector(), dPoint, getSteepestVector());
         if (dEdge.contains(pt)) {
           return pt;
         }
       }
     }
   }
   return null;
 }
Ejemplo n.º 3
0
 /**
  * Compute the intersection point according to the vector opposite to the steepest vector. If dp
  * is outside the triangle, we return null.
  *
  * @param dp
  * @return The point pt of the triangle's boundary for which (dp pt) is colinear to the steepest
  *     vector.
  * @throws DelaunayError
  */
 public final DPoint getCounterSteepestIntersection(DPoint dp) throws DelaunayError {
   if (isInside(dp) || isOnAnEdge(dp)) {
     for (DEdge ed : edges) {
       if (!isTopoOrientedToEdge(ed)) {
         DPoint counterSteep = getSteepestVector();
         counterSteep.setX(-counterSteep.getX());
         counterSteep.setY(-counterSteep.getY());
         counterSteep.setZ(-counterSteep.getZ());
         DPoint pt =
             Tools.computeIntersection(
                 ed.getStartPoint(), ed.getDirectionVector(), dp, counterSteep);
         if (ed.contains(pt)) {
           return pt;
         }
       }
     }
   }
   return null;
 }
Ejemplo n.º 4
0
 /**
  * Compute the azimut of the triangle in degrees between north and steeepest vector. Aspect is
  * measured clockwise in degrees from 0, due north, to 360, again due north, coming full circle.
  *
  * @return the aspect of the slope of this triangle.
  * @throws DelaunayError
  */
 public final double getSlopeAspect() throws DelaunayError {
   double orientationPente;
   DPoint c1 = new DPoint(0.0, 0.0, 0.0);
   DPoint c2 = getSteepestVector();
   if (c2.getZ() > 0.0) {
     c2.setX(-c2.getX());
     c2.setY(-c2.getY());
     c2.setZ(-c2.getZ());
   }
   // l'ordre des coordonnees correspond a l'orientation de l'arc
   // "sommet haut vers sommet bas"
   double angleAxeXrad = Tools.angle(c1, c2);
   // on considere que l'axe nord correspond a l'axe Y positif
   double angleAxeNordrad = Tools.PI_OVER_2 - angleAxeXrad;
   double angleAxeNorddeg = Math.toDegrees(angleAxeNordrad);
   // on renvoie toujours une valeur d'angle >= 0
   orientationPente = angleAxeNorddeg < 0.0 ? 360.0 + angleAxeNorddeg : angleAxeNorddeg;
   return orientationPente;
 }