-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplane3d.cpp
More file actions
62 lines (47 loc) · 980 Bytes
/
plane3d.cpp
File metadata and controls
62 lines (47 loc) · 980 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "plane3d.h"
Plane3D::Plane3D(QVector3D a, QVector3D b, QVector3D c)
{
QVector3D ab(b.x() - a.x(), b.y() - a.y(), b.z() - a.z());
QVector3D ac(c.x() - a.x(), c.y() - a.y(), c.z() - a.z());
QVector3D n = QVector3D::crossProduct(ab, ac);
A = n.x();
B = n.y();
C = n.z();
D = -A * b.x() - B * b.y() - C * b.z();
}
Plane3D::~Plane3D()
{
}
float Plane3D::getA() const
{
return A;
}
float Plane3D::getB() const
{
return B;
}
float Plane3D::getC() const
{
return C;
}
float Plane3D::getD() const
{
return D;
}
float Plane3D::getDistToPoint(QVector3D point) const
{
return getDistToPoint(point.x(), point.y(), point.z());
}
float Plane3D::getDistToPoint(float x, float y, float z) const
{
return float(
qAbs(
(A*x + B*y + C*z + D) /
sqrt(A*A + B*B + C*C)
)
);
}
bool Plane3D::isInside(QVector3D vect)
{
return A * vect.x() + B * vect.y() + C * vect.z() + D == 0;
}