/** * Create a new triangle with the three given edges as a basis. * * <p>An integrity check is processed while building the triangle. This constructor is the best * way to ensure that already existing edges will be linked to the good triangles, and that ther * won't be any edge duplication in the data structures. * * @param e1 * @param e2 * @param e3 * @throws DelaunayError If there is at least two edges that don't share exactly a point. */ public DTriangle(DEdge e1, DEdge e2, DEdge e3) throws DelaunayError { super(); init(); // We check the integrity of the edges given to build this triangle boolean integrityE1E2 = (e1.isExtremity(e2.getStartPoint()) && !e3.isExtremity((e2.getStartPoint()))) || (e1.isExtremity(e2.getEndPoint()) && !e3.isExtremity(e2.getEndPoint())); boolean integrityE1EptNb = (e1.isExtremity(e3.getStartPoint()) && !e2.isExtremity((e3.getStartPoint()))) || (e1.isExtremity(e3.getEndPoint()) && !e2.isExtremity(e3.getEndPoint())); boolean integrityEptNbE2 = (e2.isExtremity(e3.getStartPoint()) && !e1.isExtremity((e3.getStartPoint()))) || (e2.isExtremity(e3.getEndPoint()) && !e1.isExtremity(e3.getEndPoint())); if (integrityE1E2 && integrityE1EptNb && integrityEptNbE2) { edges[0] = e1; edges[1] = e2; edges[2] = e3; connectEdges(); computeCenter(); radius = e1.getStartPoint().squareDistance2D(xCenter, yCenter); } else { throw new DelaunayError( "Problem while generating the Triangle : " + integrityE1E2 + " " + integrityE1EptNb + " " + integrityEptNbE2); } }
/** * Create a new triangle with three input points. * * @param p1 * @param p2 * @param p3 * @throws DelaunayError */ public DTriangle(DPoint p1, DPoint p2, DPoint p3) throws DelaunayError { super(); init(); DEdge e1 = new DEdge(p1, p2); DEdge e2 = new DEdge(p2, p3); DEdge e3 = new DEdge(p3, p1); edges[0] = e1; edges[1] = e2; edges[2] = e3; connectEdges(); computeCenter(); radius = e1.getStartPoint().squareDistance2D(xCenter, yCenter); }