#ifndef __SIMPLETRI_H #define __SIMPLETRI_H #include #include "SimpleVec.h" struct SimpleTri { SimpleTri() {}; SimpleTri(const SimpleVec &a, const SimpleVec &b, const SimpleVec &c); void Init(const SimpleVec &a, const SimpleVec &b, const SimpleVec &c); SimpleVec GetNormal() const; SimpleVec GetWorldCenter() const; float GetSpatialAngle(const SimpleVec &point) const; float GetArea() const; friend std::ostream& operator<< (std::ostream &s, const SimpleTri &A); friend std::istream& operator>> (std::istream &s, SimpleTri &A); /////////////////// /// the triangle vertices SimpleVec mVertices[3]; }; // Overload << operator for C++-style output inline std::ostream& operator<< (std::ostream &s, const SimpleTri &A) { return s << "(" << A.mVertices[0] << ", " << A.mVertices[1] << ", " << A.mVertices[2] << ")"; } // Overload >> operator for C++-style input inline std::istream& operator>> (std::istream &s, SimpleTri &A) { char a; // read "(x, y, z)" return s >> a >> A.mVertices[0] >> a >> A.mVertices[1] >> a >> A.mVertices[2] >> a; } #endif