source: GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.h @ 860

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