/** * Get Z value of a specific point in the triangle Take into account triangles connected to the * edge * * @param aPoint * @return ZValuei */ public final double softInterpolateZ(DPoint aPoint) { double weight = (double) PT_NB; double zValue = interpolateZ(aPoint) * weight; // Process connected edges for (int i = 0; i < PT_NB; i++) { DEdge anEdge = edges[i]; DTriangle aTriangle = null; if (anEdge != null) { if (anEdge.getLeft() == this) { aTriangle = anEdge.getRight(); } else { aTriangle = anEdge.getLeft(); } } if (aTriangle != null) { weight += 1.0; zValue += aTriangle.interpolateZ(aPoint); } } // Define new Z value zValue /= weight; return zValue; }
/** * Used to check if this is equal to other. This and other are equal if and only if other is an * instance of DTriangle and their points are the same (whatever their order in the triangle). * * @param other * @return true if this and other are equal */ @Override public final boolean equals(Object other) { if (other instanceof DTriangle) { DTriangle otherTri = (DTriangle) other; boolean ret = belongsTo(otherTri.getPoint(0)) && belongsTo(otherTri.getPoint(1)) && belongsTo(otherTri.getPoint(2)); return ret; } else { return false; } }
/** * Implements the Comparable interface. The triangles will be sorted according the middle of their * bounding box. As we work on a triangulation where triangles' intersection can only be an edge, * a point or void, the Bounding boxes are unique. * * <p>BE CAREFUL : this method is not consistent with equals ! We are making a comparison on the * bounding box of two triangles, they could be equal even if the triangle are different !!! * * @param t * @return -1, 0 or 1, using the point comparison on the center of the bounding boxes */ @Override public final int compareTo(DTriangle t) { try { DPoint midT = getBoundingBox().getMiddle(); DPoint midO = t.getBoundingBox().getMiddle(); int c = midT.compareTo(midO); if (c == 0) { try { c = getBarycenter().compareTo(t.getBarycenter()); } catch (DelaunayError ex) { Logger.getLogger(DTriangle.class.getName()).log(Level.WARNING, null, ex); } } return c; } catch (DelaunayError e) { throw new IllegalArgumentException(e.getLocalizedMessage(), e); } }