-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplane.cpp
More file actions
119 lines (46 loc) · 1.13 KB
/
Copy pathplane.cpp
File metadata and controls
119 lines (46 loc) · 1.13 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <iostream>
#include <math.h>
#include "plane.h"
using namespace std;
vector3 plane::intersect(vector3 v1, vector3 v2) {
// find parametric form
float dx = v1.x;
float dy = v1.y;
float dz = v1.z;
float tx = (v2.x - v1.x);
float ty = (v2.y - v1.y);
float tz = (v2.z - v1.z);
// resolve t
float constant = (a * dx) + (b * dy) + (c * dz);
float tcoef = (a * tx) + (b * ty) + (c * tz);
float t = (-d - constant) / tcoef;
// resolve
float x_int = dx + (tx * t);
float y_int = dy + (ty * t);
float z_int = dz + (tz * t);
return vector3(x_int, y_int, z_int);
}
void plane::setP1(vector3 v) {
p1x = v.x; p1y = v.y; p1z = v.z;
}
void plane::setP2(vector3 v) {
p2x = v.x; p2y = v.y; p2z = v.z;
}
void plane::setP3(vector3 v) {
p3x = v.x; p3y = v.y; p3z = v.z;
}
void plane::setP4(vector3 v) {
p4x = v.x; p4y = v.y; p4z = v.z;
}
vector3 plane::getP1() {
return vector3(p1x, p1y, p1z);
}
vector3 plane::getP2() {
return vector3(p2x, p2y, p2z);
}
vector3 plane::getP3() {
return vector3(p3x, p3y, p3z);
}
vector3 plane::getP4() {
return vector3(p4x, p4y, p4z);
}