Class Polyhedron
java.lang.Object
org.episteme.core.mathematics.geometry.polyhedra.Polyhedron
- All Implemented Interfaces:
Graph<Point3D>, CollisionShape
Represents a convex polyhedron in 3D space.
A polyhedron is defined by its vertices and faces. This class supports common operations like computing surface area, volume, and checking convexity.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Nested Class Summary
Nested classes/interfaces inherited from interface Graph
Graph.Edge<V> -
Constructor Summary
ConstructorsConstructorDescriptionPolyhedron(List<Point3D> vertices, List<int[]> faces) Creates a polyhedron from vertices and faces. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds an edge between two vertices.booleanAdds a vertex to the graph.centroid()Computes the centroid (center of mass) of the polyhedron.static Polyhedroncube()Creates a cube with unit edge length centered at origin.intReturns the degree (number of edges) of a vertex.static PolyhedronCreates a regular dodecahedron as the dual of the icosahedron.intReturns the number of edges (using Euler's formula for convex polyhedra: V - E + F = 2).edges()Returns all edges in this graph.intReturns the number of faces.getAABB()compute AABB (Axis Aligned Bounding Box).getFaceVertices(int faceIndex) Returns the vertices of the face at the given index.getSupportPoint(Vector<Real> direction) Gets the support point in a given direction (furthest point in that direction).getVertex(int index) Returns the vertex at the given index.static PolyhedronCreates a regular icosahedron.booleanChecks if this graph is directed.booleanReturns true if the polyhedron satisfies Euler's formula (V - E + F = 2).Returns neighbors of a vertex.static PolyhedronCreates a regular octahedron with unit edge length.Computes the surface area of the polyhedron.static PolyhedronCreates a regular tetrahedron with unit edge length.toString()intReturns the number of vertices.vertices()Returns all vertices in this graph.volume()Computes the volume of a convex polyhedron using the divergence theorem.
-
Constructor Details
-
Polyhedron
-
-
Method Details
-
vertexCount
public int vertexCount()Returns the number of vertices.- Specified by:
vertexCountin interfaceGraph<Point3D>- Returns:
- the number of vertices
-
faceCount
public int faceCount()Returns the number of faces. -
edgeCount
public int edgeCount()Returns the number of edges (using Euler's formula for convex polyhedra: V - E + F = 2). -
getVertex
Returns the vertex at the given index. -
getFaceVertices
-
centroid
Computes the centroid (center of mass) of the polyhedron. -
surfaceArea
Computes the surface area of the polyhedron. -
volume
Computes the volume of a convex polyhedron using the divergence theorem. -
isValidEuler
public boolean isValidEuler()Returns true if the polyhedron satisfies Euler's formula (V - E + F = 2). -
vertices
-
edges
-
addVertex
-
addEdge
-
neighbors
-
degree
-
isDirected
public boolean isDirected()Description copied from interface:GraphChecks if this graph is directed.- Specified by:
isDirectedin interfaceGraph<Point3D>- Returns:
- true if directed, false if undirected
-
tetrahedron
Creates a regular tetrahedron with unit edge length. -
cube
Creates a cube with unit edge length centered at origin. -
octahedron
Creates a regular octahedron with unit edge length. -
icosahedron
Creates a regular icosahedron. -
dodecahedron
Creates a regular dodecahedron as the dual of the icosahedron. -
getSupportPoint
Description copied from interface:CollisionShapeGets the support point in a given direction (furthest point in that direction). Used for GJK and SAT algorithms.- Specified by:
getSupportPointin interfaceCollisionShape- Parameters:
direction- the direction vector- Returns:
- the support point in local coordinates
-
getAABB
Description copied from interface:CollisionShapecompute AABB (Axis Aligned Bounding Box).- Specified by:
getAABBin interfaceCollisionShape- Returns:
- array of two Vectors {min, max}
-
toString
-