Line | |
---|
1 | #ifndef _Plane3_H__ |
---|
2 | #define _Plane3_H__ |
---|
3 | |
---|
4 | #include "Vector3.h" |
---|
5 | |
---|
6 | |
---|
7 | /** 3D Plane */ |
---|
8 | class Plane3 { |
---|
9 | public: |
---|
10 | Vector3 mNormal; |
---|
11 | float mD; |
---|
12 | |
---|
13 | Plane3() {} |
---|
14 | |
---|
15 | Plane3(const Vector3 &a, |
---|
16 | const Vector3 &b, |
---|
17 | const Vector3 &c |
---|
18 | ) { |
---|
19 | Vector3 v1=a-b, v2=c-b; |
---|
20 | mNormal = Normalize(CrossProd(v2,v1)); |
---|
21 | mD = -DotProd(b, mNormal); |
---|
22 | |
---|
23 | } |
---|
24 | |
---|
25 | float Distance(const Vector3 &v) const { |
---|
26 | return DotProd(v, mNormal) + mD; |
---|
27 | } |
---|
28 | |
---|
29 | int Side(const Vector3 &v, const float threshold = 1e-6) const { |
---|
30 | return signum(Distance(v), threshold); |
---|
31 | } |
---|
32 | |
---|
33 | friend ostream &operator<<(ostream &s, const Plane3 p) { |
---|
34 | s<<p.mNormal<<" "<<p.mD; |
---|
35 | return s; |
---|
36 | } |
---|
37 | |
---|
38 | }; |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.