Class SimpleTriangle3D
- java.lang.Object
-
- org.apache.commons.geometry.euclidean.threed.AbstractPlaneSubset
-
- org.apache.commons.geometry.euclidean.threed.AbstractConvexPolygon3D
-
- org.apache.commons.geometry.euclidean.threed.SimpleTriangle3D
-
- All Implemented Interfaces:
HyperplaneConvexSubset<Vector3D>
,HyperplaneSubset<Vector3D>
,Splittable<Vector3D,HyperplaneSubset<Vector3D>>
,Sized
,ConvexPolygon3D
,PlaneConvexSubset
,PlaneSubset
,Triangle3D
final class SimpleTriangle3D extends AbstractConvexPolygon3D implements Triangle3D
Simple implementation ofTriangle3D
.Instances of this class are guaranteed to be immutable.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneConvexSubset
PlaneConvexSubset.Embedded
-
Nested classes/interfaces inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneSubset
PlaneSubset.Embedded
-
-
Constructor Summary
Constructors Constructor Description SimpleTriangle3D(Plane plane, Vector3D p1, Vector3D p2, Vector3D p3)
Construct a new instance from a plane and 3 points.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector3D
getCentroid()
Get the centroid, or geometric center, of the hyperplane subset or null if no centroid exists or one exists but is not unique.Vector3D
getPoint1()
The first point in the triangle.Vector3D
getPoint2()
The second point in the triangle.Vector3D
getPoint3()
The third point in the triangle.double
getSize()
Get the size of the instance.java.util.List<Vector3D>
getVertices()
Get the vertices for the convex subset in a counter-clockwise order as viewed looking down the plane normal.SimpleTriangle3D
reverse()
Reverse the orientation of the hyperplane for this instance, returning the result as a new instance.SimpleTriangle3D
transform(Transform<Vector3D> transform)
Return a new hyperplane subset resulting from the application of the given transform.-
Methods inherited from class org.apache.commons.geometry.euclidean.threed.AbstractConvexPolygon3D
classify, closest, getBounds, getEmbedded, getPlane, isEmpty, isFull, split, toString
-
Methods inherited from class org.apache.commons.geometry.euclidean.threed.AbstractPlaneSubset
getHyperplane, intersection, intersection
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.geometry.core.partitioning.HyperplaneSubset
classify, closest, contains, isEmpty, isFull
-
Methods inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneConvexSubset
getEmbedded, split, toConvex
-
Methods inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneSubset
getBounds, getHyperplane, getPlane, intersection, intersection
-
Methods inherited from interface org.apache.commons.geometry.core.Sized
isFinite, isInfinite
-
Methods inherited from interface org.apache.commons.geometry.euclidean.threed.Triangle3D
toTriangles
-
-
-
-
Constructor Detail
-
SimpleTriangle3D
SimpleTriangle3D(Plane plane, Vector3D p1, Vector3D p2, Vector3D p3)
Construct a new instance from a plane and 3 points. Callers are responsible for ensuring that the points lie on the plane and define a triangle. No validation is performed.- Parameters:
plane
- the plane containing the trianglep1
- first point in the trianglep2
- second point in the trianglep3
- third point in the triangle
-
-
Method Detail
-
getPoint1
public Vector3D getPoint1()
The first point in the triangle.- Specified by:
getPoint1
in interfaceTriangle3D
- Returns:
- the first point in the triangle
-
getPoint2
public Vector3D getPoint2()
The second point in the triangle.- Specified by:
getPoint2
in interfaceTriangle3D
- Returns:
- the second point in the triangle
-
getPoint3
public Vector3D getPoint3()
The third point in the triangle.- Specified by:
getPoint3
in interfaceTriangle3D
- Returns:
- the third point in the triangle
-
getVertices
public java.util.List<Vector3D> getVertices()
Get the vertices for the convex subset in a counter-clockwise order as viewed looking down the plane normal. Each vertex in the returned list is unique. If the boundary of the subset is closed, the start vertex is not repeated at the end of the list.It is important to note that, in general, the list of vertices returned by this method is not sufficient to completely characterize the subset. For example, a simple triangle has 3 vertices, but an infinite area constructed from two parallel lines and two lines that intersect between them will also have 3 vertices. It is also possible for non-empty subsets to contain no vertices at all. For example, a subset with no boundaries (representing the full plane), a subset with a single boundary (ie, a half-plane), or a subset with two parallel boundaries will not contain any vertices.
- Specified by:
getVertices
in interfacePlaneConvexSubset
- Returns:
- the list of vertices for the plane convex subset in a counter-clockwise order as viewed looking down the plane normal
-
getSize
public double getSize()
Get the size of the instance.- Specified by:
getSize
in interfaceSized
- Overrides:
getSize
in classAbstractConvexPolygon3D
- Returns:
- the size of the instance
-
getCentroid
public Vector3D getCentroid()
Get the centroid, or geometric center, of the hyperplane subset or null if no centroid exists or one exists but is not unique. A centroid will not exist for empty or infinite subsets.The centroid of a geometric object is defined as the mean position of all points in the object, including interior points, vertices, and other points lying on the boundary. If a physical object has a uniform density, then its center of mass is the same as its geometric centroid.
- Specified by:
getCentroid
in interfaceHyperplaneSubset<Vector3D>
- Overrides:
getCentroid
in classAbstractConvexPolygon3D
- Returns:
- the centroid of the hyperplane subset or null if no unique centroid exists
- See Also:
- Centroid
-
reverse
public SimpleTriangle3D reverse()
Reverse the orientation of the hyperplane for this instance, returning the result as a new instance. The returned subset contains the same points but has a reversed orientation.- Specified by:
reverse
in interfaceConvexPolygon3D
- Specified by:
reverse
in interfaceHyperplaneConvexSubset<Vector3D>
- Specified by:
reverse
in interfacePlaneConvexSubset
- Specified by:
reverse
in interfaceTriangle3D
- Returns:
- a hyperplane convex subset representing the same region but with the opposite orientation.
-
transform
public SimpleTriangle3D transform(Transform<Vector3D> transform)
Return a new hyperplane subset resulting from the application of the given transform. The current instance is not modified.- Specified by:
transform
in interfaceConvexPolygon3D
- Specified by:
transform
in interfaceHyperplaneConvexSubset<Vector3D>
- Specified by:
transform
in interfaceHyperplaneSubset<Vector3D>
- Specified by:
transform
in interfacePlaneConvexSubset
- Specified by:
transform
in interfaceTriangle3D
- Parameters:
transform
- the transform instance to apply- Returns:
- new transformed hyperplane subset
-
-