Class ComputationalGeometry3D

java.lang.Object
org.episteme.core.mathematics.geometry.ComputationalGeometry3D

public class ComputationalGeometry3D extends Object
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 Details

    • closestPair

      public static Point3D[] closestPair(List<Point3D> points)
      Closest pair of points in 3D - O(n log n) divide and conquer.
      Parameters:
      points - the input points
      Returns:
      array of two closest points, or null if fewer than 2 points
    • convexHull

      public static List<List<Point3D>> convexHull(List<Point3D> points)
      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 test
      v0 - first vertex of tetrahedron
      v1 - second vertex of tetrahedron
      v2 - third vertex of tetrahedron
      v3 - fourth vertex of tetrahedron
      Returns:
      true if point is inside the tetrahedron
    • tetrahedronVolume

      public static Real tetrahedronVolume(Point3D v0, Point3D v1, Point3D v2, Point3D v3)
      Computes the volume of a tetrahedron.
    • centroid

      public static Point3D centroid(List<Point3D> points)
      Computes the centroid of a set of 3D points.
    • intersectRayTriangle

      public static Real intersectRayTriangle(Ray3D ray, Point3D v0, Point3D v1, Point3D v2)
      Intersects a ray with a triangle. Uses Möller–Trumbore intersection algorithm.
      Parameters:
      ray - the ray
      v0 - first vertex of triangle
      v1 - second vertex of triangle
      v2 - third vertex of triangle
      Returns:
      the distance t from ray origin to intersection, or null if no intersection
    • intersectRaySphere

      public static Real intersectRaySphere(Ray3D ray, Point3D center, Real radius)
      Intersects a ray with a sphere.
      Parameters:
      ray - the ray
      center - center of the sphere
      radius - radius of the sphere
      Returns:
      distance to the closest intersection point, or null if no intersection
    • intersectRayPlane

      public static Real intersectRayPlane(Ray3D ray, Point3D planePoint, Vector3D planeNormal)
      Intersects a ray with a plane.
      Parameters:
      ray - the ray
      planePoint - a point on the plane
      planeNormal - the normal of the plane
      Returns:
      distance to intersection, or null if parallel