Sha256: 86c1018ab8fd262e6cb9da65979461f72feafd316e68f4c2cd470539b3d2596a
Contents?: true
Size: 1.17 KB
Versions: 11
Compression:
Stored size: 1.17 KB
Contents
package toxi.geom; import toxi.math.MathUtils; /** * * @author tux */ public class PlaneIntersector implements Intersector3D { private Plane plane; private final IsectData3D isec; /** * * @param p */ public PlaneIntersector(Plane p) { this.plane = p; this.isec = new IsectData3D(); } @Override public IsectData3D getIntersectionData() { return isec; } /** * @return the box */ public Plane getPlane() { return plane; } @Override public boolean intersectsRay(Ray3D ray) { float d = -plane.normal.dot(plane); float numer = plane.normal.dot(ray) + d; float denom = plane.normal.dot(ray.dir); // normal is orthogonal to vector, can't intersect if (isec.isIntersection = (MathUtils.abs(denom) >= MathUtils.EPS)) { isec.dist = -(numer / denom); isec.pos = ray.getPointAtDistance(isec.dist); isec.normal = plane.normal; } return isec.isIntersection; } /** * @param p * the plane to set */ public void setPlane(Plane p) { this.plane = p; } }
Version data entries
11 entries across 11 versions & 1 rubygems