Line | |
---|
1 | #ifndef __TRIANGLE3_H
|
---|
2 | #define __TRIANGLE3_H
|
---|
3 |
|
---|
4 | #include "Vector3.h"
|
---|
5 |
|
---|
6 | struct Triangle3 {
|
---|
7 |
|
---|
8 | Vector3 mVertices[3];
|
---|
9 |
|
---|
10 | Triangle3() {}
|
---|
11 | Triangle3(const Vector3 &a,
|
---|
12 | const Vector3 &b,
|
---|
13 | const Vector3 &c
|
---|
14 | ) {
|
---|
15 | Init(a, b, c);
|
---|
16 | }
|
---|
17 |
|
---|
18 | void
|
---|
19 | Init(const Vector3 &a,
|
---|
20 | const Vector3 &b,
|
---|
21 | const Vector3 &c
|
---|
22 | ) {
|
---|
23 | mVertices[0] = a;
|
---|
24 | mVertices[1] = b;
|
---|
25 | mVertices[2] = c;
|
---|
26 |
|
---|
27 | }
|
---|
28 |
|
---|
29 | Vector3 GetNormal() const {
|
---|
30 | Vector3 v1=mVertices[0]-mVertices[1], v2=mVertices[2]-mVertices[1];
|
---|
31 | return Normalize(CrossProd(v2,v1));
|
---|
32 | }
|
---|
33 |
|
---|
34 | Vector3 GetCenter() const {
|
---|
35 | return (mVertices[0] + mVertices[1] + mVertices[2])/3.0f;
|
---|
36 | }
|
---|
37 |
|
---|
38 | float GetSpatialAngle(const Vector3 &point) const;
|
---|
39 |
|
---|
40 | float GetArea() const {
|
---|
41 | Vector3 v1=mVertices[0]-mVertices[1], v2=mVertices[2]-mVertices[1];
|
---|
42 | return 0.5f * Magnitude(CrossProd(v2, v1));
|
---|
43 | }
|
---|
44 | };
|
---|
45 |
|
---|
46 |
|
---|
47 | #endif
|
---|
48 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.