package graphics; public class Polyhedron extends Shape { //half-space planes Plane[] planes; public Polyhedron(Plane[] planes) { this.planes = planes; this.matrix = new Matrix3D(); } //returns array of t values (roots) or void if no intersection //sets point of intersection and normal there public double[] testRay(Vector3 v, Vector3 w, Vector3 pos, Vector3 normal) { if (planes == null || planes.length == 0) { System.err.println("Warning - null or empty set of planes for Polyhedron!"); return null; } //indices of intersection planes int enterPlane = -1, exitPlane = -1; //t values of each plane double[] planeRoots = new double[planes.length]; //keep track of what the normal of each plane is Vector3[] planeNormals = new Vector3[planes.length]; double t; //want max enter, min exit double tEnter = Double.NEGATIVE_INFINITY, tExit = Double.POSITIVE_INFINITY; for (int i = 0; i