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

Version Path
toxiclibs-2.1.0 src/main/java/toxi/geom/PlaneIntersector.java
toxiclibs-2.0.0 src/main/java/toxi/geom/PlaneIntersector.java
toxiclibs-1.0.0 src/toxi/geom/PlaneIntersector.java
toxiclibs-0.9.3 src/toxi/geom/PlaneIntersector.java
toxiclibs-0.9.2 src/toxi/geom/PlaneIntersector.java
toxiclibs-0.9.1 src/toxi/geom/PlaneIntersector.java
toxiclibs-0.9.0 src/toxi/geom/PlaneIntersector.java
toxiclibs-0.8.0 src/toxi/geom/PlaneIntersector.java
toxiclibs-0.6.0-java src/toxi/geom/PlaneIntersector.java
toxiclibs-0.5.1-java src/toxi/geom/PlaneIntersector.java
toxiclibs-0.5.0-java src/toxi/geom/PlaneIntersector.java