[216] | 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 2 | /** |
---|
| 3 | * Contains a handy triangle class. |
---|
| 4 | * \file IceTriangle.h |
---|
| 5 | * \author Pierre Terdiman |
---|
| 6 | * \date January, 17, 2000 |
---|
| 7 | */ |
---|
| 8 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 9 | |
---|
| 10 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 11 | // Include Guard |
---|
| 12 | #ifndef __ICETRIANGLE_H__ |
---|
| 13 | #define __ICETRIANGLE_H__ |
---|
| 14 | |
---|
| 15 | // Forward declarations |
---|
| 16 | class Moment; |
---|
| 17 | |
---|
| 18 | // Partitioning values |
---|
| 19 | enum PartVal |
---|
| 20 | { |
---|
| 21 | TRI_MINUS_SPACE = 0, //!< Triangle is in the negative space |
---|
| 22 | TRI_PLUS_SPACE = 1, //!< Triangle is in the positive space |
---|
| 23 | TRI_INTERSECT = 2, //!< Triangle intersects plane |
---|
| 24 | TRI_ON_PLANE = 3, //!< Triangle and plane are coplanar |
---|
| 25 | |
---|
| 26 | TRI_FORCEDWORD = 0x7fffffff |
---|
| 27 | }; |
---|
| 28 | |
---|
| 29 | // A triangle class. |
---|
| 30 | class ICEMATHS_API Triangle |
---|
| 31 | { |
---|
| 32 | public: |
---|
| 33 | //! Constructor |
---|
| 34 | inline_ Triangle() {} |
---|
| 35 | //! Constructor |
---|
| 36 | inline_ Triangle(const Point& p0, const Point& p1, const Point& p2) { mVerts[0]=p0; mVerts[1]=p1; mVerts[2]=p2; } |
---|
| 37 | //! Copy constructor |
---|
| 38 | inline_ Triangle(const Triangle& triangle) |
---|
| 39 | { |
---|
| 40 | mVerts[0] = triangle.mVerts[0]; |
---|
| 41 | mVerts[1] = triangle.mVerts[1]; |
---|
| 42 | mVerts[2] = triangle.mVerts[2]; |
---|
| 43 | } |
---|
| 44 | //! Destructor |
---|
| 45 | inline_ ~Triangle() {} |
---|
| 46 | //! Vertices |
---|
| 47 | Point mVerts[3]; |
---|
| 48 | |
---|
| 49 | // Methods |
---|
| 50 | void Flip(); |
---|
| 51 | float Area() const; |
---|
| 52 | float Perimeter() const; |
---|
| 53 | float Compacity() const; |
---|
| 54 | void Normal(Point& normal) const; |
---|
| 55 | void DenormalizedNormal(Point& normal) const; |
---|
| 56 | void Center(Point& center) const; |
---|
| 57 | inline_ Plane PlaneEquation() const { return Plane(mVerts[0], mVerts[1], mVerts[2]); } |
---|
| 58 | |
---|
| 59 | PartVal TestAgainstPlane(const Plane& plane, float epsilon) const; |
---|
| 60 | // float Distance(Point& cp, Point& cq, Tri& tri); |
---|
| 61 | void ComputeMoment(Moment& m); |
---|
| 62 | float MinEdgeLength() const; |
---|
| 63 | float MaxEdgeLength() const; |
---|
| 64 | void ComputePoint(float u, float v, Point& pt, udword* nearvtx=null) const; |
---|
| 65 | void Inflate(float fat_coeff, bool constant_border); |
---|
| 66 | }; |
---|
| 67 | |
---|
| 68 | #endif // __ICETRIANGLE_H__ |
---|