-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlane.cpp
More file actions
38 lines (31 loc) · 835 Bytes
/
Copy pathPlane.cpp
File metadata and controls
38 lines (31 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "Plane.h"
#include "Vector.h"
#include "Ray.h"
#include "Utility.h"
// Default Constructor
Plane::Plane() {
}
// Create a set of "plane data" along a specified 3D plane
Plane::Plane(Vector plane) {
m_plane = plane;
}
// Setter: change the plane the "plane data" runs along
void Plane::setPlane(Vector plane) {
m_plane = plane;
}
// Getter: get the the plane the "plane data" runs along
Vector Plane::getPlane() {
return m_plane;
}
// Plane intersect test
bool Plane::intersectsPlane(Vector& n, Vector& p0, Vector& l0, Vector& l, IntersectInfo& i) {
// assuming all vectors are normalized
Utility util;
float denominator = util.dot3D(n, l);
if (denominator > 0.0f) {
Vector p0l0 = p0 - l0;
i.t = util.dot3D(p0l0, n) / denominator;
return (i.t >= 0);
}
return false;
}