java.lang.Object
imagingbook.common.geometry.delaunay.guibas.Triangle2D
- All Implemented Interfaces:
Triangle,ShapeProducer
Represents a 2D triangle, specified by three corner points. Instances of this class are immutable.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTriangle2D(Pnt2d[] points) Triangle2D(Pnt2d a, Pnt2d b, Pnt2d c) Constructor of the 2D triangle class used to create a new triangle instance from three 2D vectors describing the triangle's vertices. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsEdge(Edge2D edge) Returnstrueif this triangle contains the given edge.booleancontainsPoint(Pnt2d point) Tests if a 2D point lies inside this 2D triangle.findMinEdgeDistance(Pnt2d point) Calculates the minimum distance from the specified point to this triangle.getOppositeVertex(Edge2D edge) Returns the vertex of this triangle opposite to the specified edge.Pnt2d[]Returns an array of points used by the triangulation in the order of their insertion.booleanChecks if the given vertex is amongst the triangle's vertices.protected booleanTest if this triangle is oriented counterclockwise (CCW).protected booleanisPointInCircumCircle(Pnt2d point) Tests if a given point lies in the circumcircle of this triangle.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface imagingbook.common.geometry.shape.ShapeProducer
getShape, getShapes, getShapes
-
Field Details
-
a
-
b
-
c
-
-
Constructor Details
-
Triangle2D
Constructor of the 2D triangle class used to create a new triangle instance from three 2D vectors describing the triangle's vertices.- Parameters:
a- the first vertex of the triangleb- the second vertex of the trianglec- the third vertex of the triangle
-
Triangle2D
-
-
Method Details
-
containsPoint
Tests if a 2D point lies inside this 2D triangle. See See Christer Ericson, Real-Time Collision Detection, CRC Press, 2004 (Ch. 5, p. 206).- Parameters:
point- the point to be checked- Returns:
trueiff the point lies inside this 2D triangle
-
isPointInCircumCircle
Tests if a given point lies in the circumcircle of this triangle. Let the triangle ABC appear in counterclockwise (CCW) order. Then when det > 0, the point lies inside the circumcircle through the three points a, b and c. If instead det < 0, the point lies outside the circumcircle. When det = 0, the four points are cocircular. If the triangle is oriented clockwise (CW) the result is reversed. See Christer Ericson, Real-Time Collision Detection, CRC Press, 2004 (Ch. 3, p. 34).- Parameters:
point- the point to be checked- Returns:
trueiff the point lies inside the circumcircle through the three points a, b, and c of the triangle
-
isOrientedCCW
Test if this triangle is oriented counterclockwise (CCW). This property is pre-calculated.- Returns:
trueiff the triangle ABC is oriented counterclockwise (CCW)
-
containsEdge
Returnstrueif this triangle contains the given edge.- Parameters:
edge- the edge to be tested- Returns:
trueiff this triangle contains the specified edge
-
getOppositeVertex
Returns the vertex of this triangle opposite to the specified edge.- Parameters:
edge- the edge (which must be contained in this triangle)- Returns:
- the triangle vertex opposite to the specified edge
-
hasVertex
Checks if the given vertex is amongst the triangle's vertices.- Parameters:
vertex- the vertex to be checked- Returns:
trueif the vertex is one of the corners of this triangle
-
findMinEdgeDistance
Calculates the minimum distance from the specified point to this triangle. The result is returned as anEdge2D.Distanceinstance, representing the point's distance to the closest edge of this triangle.- Parameters:
point- the point to be checked- Returns:
- the edge of this triangle that is closest to the specified point
-
toString
-
getPoints
Description copied from interface:TriangleReturns an array of points used by the triangulation in the order of their insertion.
-