34 package eu.mihosoft.vrl.v3d;
37 import java.util.ArrayList;
38 import java.util.List;
55 public static final double EPSILON = 1.0e-9;
137 List<Polygon> coplanarFront,
138 List<Polygon> coplanarBack,
140 List<Polygon> back) {
141 final int COPLANAR = 0;
144 final int SPANNING = 3;
155 for (
int i = 0; i < polygon.
vertices.size(); i++) {
167 List<Integer> types =
new ArrayList<>();
168 boolean somePointsInfront =
false;
169 boolean somePointsInBack =
false;
170 for (
int i = 0; i < polygon.
vertices.size(); i++) {
172 int type = (t < negEpsilon) ? BACK : (t > posEpsilon) ? FRONT : COPLANAR;
175 somePointsInBack=
true;
177 somePointsInfront =
true;
180 if(somePointsInBack && somePointsInfront)
181 polygonType=SPANNING;
182 else if(somePointsInBack) {
184 }
else if(somePointsInfront)
189 switch (polygonType) {
192 (this.normal.
dot(polygon.
plane.
normal) > 0 ? coplanarFront : coplanarBack).add(polygon);
204 List<Vertex> f =
new ArrayList<>();
205 List<Vertex> b =
new ArrayList<>();
206 for (
int i = 0; i < polygon.
vertices.size(); i++) {
207 int j = (i + 1) % polygon.
vertices.size();
208 int ti = types.get(i);
209 int tj = types.get(j);
216 b.add(ti != BACK ? vi.
clone() : vi);
218 if ((ti | tj) == SPANNING) {
219 double t = (this.dist - this.normal.
dot(vi.
pos))
229 System.out.println(
"Front Clip Fault!");
234 System.out.println(
"Back Clip Fault!");
void splitPolygon(Polygon polygon, List< Polygon > coplanarFront, List< Polygon > coplanarBack, List< Polygon > front, List< Polygon > back)
static boolean isUseDebugger()
static final double EPSILON
static IPolygonDebugger getDebugger()
static final Plane XZ_PLANE
static final Plane XY_PLANE
static void setDebugger(IPolygonDebugger debugger)
static void setUseDebugger(boolean useDebugger)
static Plane createFromPoints(Vector3d a, Vector3d b, Vector3d c)
static final double EPSILON_Point
static final double EPSILON_duplicate
static final Plane YZ_PLANE
static boolean useDebugger
Plane(Vector3d normal, double dist)
static IPolygonDebugger debugger
final List< Vertex > vertices
PropertyStorage getStorage()
Vector3d cross(Vector3d a)
static final Vector3d X_ONE
Vector3d minus(Vector3d v)
static final Vector3d Z_ONE
static final Vector3d Y_ONE
Vertex interpolate(Vertex other, double t)