Class ComputationalGeometry3D
java.lang.Object
org.episteme.core.mathematics.geometry.ComputationalGeometry3D
Computational geometry algorithms for 3D.
Includes: convex hull, closest pair, plane intersections, etc.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptionstatic Point3DComputes the centroid of a set of 3D points.static Point3D[]closestPair(List<Point3D> points) Closest pair of points in 3D - O(n log n) divide and conquer.convexHull(List<Point3D> points) Computes the convex hull in 3D using the Gift Wrapping algorithm.static RealintersectRayPlane(Ray3D ray, Point3D planePoint, Vector3D planeNormal) Intersects a ray with a plane.static RealintersectRaySphere(Ray3D ray, Point3D center, Real radius) Intersects a ray with a sphere.static RealintersectRayTriangle(Ray3D ray, Point3D v0, Point3D v1, Point3D v2) Intersects a ray with a triangle.static booleanChecks if a point is inside a tetrahedron.static RealtetrahedronVolume(Point3D v0, Point3D v1, Point3D v2, Point3D v3) Computes the volume of a tetrahedron.
-
Method Details
-
closestPair
-
convexHull
Computes the convex hull in 3D using the Gift Wrapping algorithm.Returns a list of triangular faces, each represented as a list of 3 points. This is a simple O(n*h) algorithm where h is the number of hull faces.
- Parameters:
points- the input points- Returns:
- list of triangular faces forming the convex hull
-
pointInTetrahedron
public static boolean pointInTetrahedron(Point3D point, Point3D v0, Point3D v1, Point3D v2, Point3D v3) Checks if a point is inside a tetrahedron.- Parameters:
point- the point to testv0- first vertex of tetrahedronv1- second vertex of tetrahedronv2- third vertex of tetrahedronv3- fourth vertex of tetrahedron- Returns:
- true if point is inside the tetrahedron
-
tetrahedronVolume
-
centroid
-
intersectRayTriangle
Intersects a ray with a triangle. Uses Möller–Trumbore intersection algorithm.- Parameters:
ray- the rayv0- first vertex of trianglev1- second vertex of trianglev2- third vertex of triangle- Returns:
- the distance t from ray origin to intersection, or null if no intersection
-
intersectRaySphere
-
intersectRayPlane
-