#include "Plane.h"
#include "Ray.h"

bool Plane::intersect(
    const Ray & ray, const double min_t, double & t, Eigen::Vector3d & n) const
{
    /* Based on
     * Computer Graphics, Chapter 4. Ray Tracing
     * Peter Lamber & Glenn Van Wallendael
     */

    t = -1;
    t = (point - ray.origin).dot(normal) / ray.direction.dot(normal);
    n = normal;

    return min_t < t;
}
