16 lines
380 B
C++
16 lines
380 B
C++
#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 Lambert & Glenn Van Wallendael
|
|
*/
|
|
|
|
t = -1;
|
|
t = (point - ray.origin).dot(normal) / ray.direction.dot(normal);
|
|
n = normal;
|
|
|
|
return min_t < t;
|
|
}
|