Package toxi.geom
Class Triangle2D
java.lang.Object
toxi.geom.Triangle2D
- All Implemented Interfaces:
Shape2D
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadjustTriangleSizeBy(float offset) adjustTriangleSizeBy(float offAB, float offBC, float offCA) booleanChecks if the given point is inside the triangle created by the points a, b and c.copy()static Triangle2DfloatgetArea()Computes the area of the shape.Computes the bounding circle of the shape.Returns the shape's axis-aligned bounding rect.floatComputes the shape's circumference.Finds and returns the closest point on any of the triangle edges to the point given.getEdges()Returns a list of the shape's perimeter edges.Creates a random point within the triangle using barycentric coordinates.Vec2D[]Vec2D[]getVertexArray(Vec2D[] array, int offset) booleanChecks if this triangle intersects the given one.booleanstatic booleanisClockwise(Vec2D a, Vec2D b, Vec2D c) voidProduces the barycentric coordinates of the given point within this triangle.Creates aPolygon2Dinstance of the triangle.toString()
-
Field Details
-
a
-
b
-
c
-
centroid
-
-
Constructor Details
-
Triangle2D
public Triangle2D() -
Triangle2D
-
-
Method Details
-
createEquilateralFrom
-
isClockwise
-
adjustTriangleSizeBy
-
adjustTriangleSizeBy
-
computeCentroid
-
containsPoint
Checks if the given point is inside the triangle created by the points a, b and c. The triangle vertices are inclusive themselves.- Specified by:
containsPointin interfaceShape2D- Returns:
- true, if point is in triangle.
-
copy
-
flipVertexOrder
-
fromBarycentric
-
getArea
public float getArea()Description copied from interface:Shape2DComputes the area of the shape. -
getBoundingCircle
Description copied from interface:Shape2DComputes the bounding circle of the shape.- Specified by:
getBoundingCirclein interfaceShape2D- Returns:
- circle
-
getBounds
Description copied from interface:Shape2DReturns the shape's axis-aligned bounding rect. -
getCircumCircle
-
getCircumference
public float getCircumference()Description copied from interface:Shape2DComputes the shape's circumference.- Specified by:
getCircumferencein interfaceShape2D- Returns:
- circumference
-
getClosestPointTo
Finds and returns the closest point on any of the triangle edges to the point given.- Parameters:
p- point to check- Returns:
- closest point
-
getEdges
Description copied from interface:Shape2DReturns a list of the shape's perimeter edges. -
getRandomPoint
Creates a random point within the triangle using barycentric coordinates.- Specified by:
getRandomPointin interfaceShape2D- Returns:
- Vec2D
-
getVertexArray
-
getVertexArray
-
intersectsTriangle
Checks if this triangle intersects the given one. The check handles both partial and total containment as well as intersections of all edges.- Parameters:
tri-- Returns:
- true, if intersecting
-
isClockwise
public boolean isClockwise() -
set
-
toBarycentric
Produces the barycentric coordinates of the given point within this triangle. These coordinates can then be used to re-project the point into a different triangle using itsfromBarycentric(ReadonlyVec3D)method.- Parameters:
p- point in world space- Returns:
- barycentric coords as
Vec3D
-
toPolygon2D
Creates aPolygon2Dinstance of the triangle. The vertices of this polygon are disconnected from the ones defining this triangle.- Specified by:
toPolygon2Din interfaceShape2D- Returns:
- triangle as polygon
-
toString
-