Class Plane
Planes are fundamental to BSP (Binary Space Partitioning) tree operations in CSG. They divide 3D space into two half-spaces.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a deep clone of this plane.static booleancomputeNormal(Point3D a, Point3D b, Point3D c, Point3D result) Computes the unit normal vector for a triangle defined by three points.voidflip()Flips the plane orientation by negating the normal and distance.static PlanefromPoints(Point3D a, Point3D b, Point3D c) Creates a plane from three non-collinear points.voidsplitPolygon(SolidPolygon polygon, List<SolidPolygon> coplanarFront, List<SolidPolygon> coplanarBack, List<SolidPolygon> front, List<SolidPolygon> back) Splits a polygon by this plane, classifying and potentially dividing it.
-
Field Details
-
EPSILON
public static final double EPSILONEpsilon value used for floating-point comparisons in BSP operations. Smaller values provide higher precision but may cause issues with near-coplanar polygons. 1e-5 is a good balance for most 3D geometry.- See Also:
-
normal
The unit normal vector perpendicular to the plane surface. -
distance
public double distanceThe signed distance from the origin to the plane along the normal.
-
-
Constructor Details
-
Plane
Creates a plane with the given normal and distance.- Parameters:
normal- the unit normal vectordistance- the signed distance from origin to the plane
-
-
Method Details
-
computeNormal
Computes the unit normal vector for a triangle defined by three points.Zero-allocation method: fills the result point instead of creating a new one. This is the shared implementation used by both
fromPoints(eu.svjatoslav.sixth.e3d.geometry.Point3D, eu.svjatoslav.sixth.e3d.geometry.Point3D, eu.svjatoslav.sixth.e3d.geometry.Point3D)andSolidPolygonfor shading calculations.The normal is computed as the cross product of two edge vectors (b-a and c-a), then normalized to unit length.
- Parameters:
a- first point (base point for edge vectors)b- second pointc- third pointresult- Point3D to receive the unit normal vector (modified in place)- Returns:
- true if normal computed successfully, false if points are collinear (cross product magnitude less than EPSILON)
-
fromPoints
Creates a plane from three non-collinear points.Uses
computeNormal(eu.svjatoslav.sixth.e3d.geometry.Point3D, eu.svjatoslav.sixth.e3d.geometry.Point3D, eu.svjatoslav.sixth.e3d.geometry.Point3D, eu.svjatoslav.sixth.e3d.geometry.Point3D)for the normal calculation, then computes the signed distance from origin using the dot product.- Parameters:
a- the first point on the planeb- the second point on the planec- the third point on the plane- Returns:
- a new Plane passing through the three points
- Throws:
ArithmeticException- if the points are collinear (cannot define a plane)
-
clone
Creates a deep clone of this plane. -
flip
public void flip()Flips the plane orientation by negating the normal and distance. -
splitPolygon
public void splitPolygon(SolidPolygon polygon, List<SolidPolygon> coplanarFront, List<SolidPolygon> coplanarBack, List<SolidPolygon> front, List<SolidPolygon> back) Splits a polygon by this plane, classifying and potentially dividing it.- Parameters:
polygon- the polygon to classify and potentially splitcoplanarFront- list to receive coplanar polygons with same-facing normalscoplanarBack- list to receive coplanar polygons with opposite-facing normalsfront- list to receive polygons in the front half-spaceback- list to receive polygons in the back half-space
-