www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

triangle.hh (1934B)


      1 #ifndef _GEOMETRY_TRIANGLE_HH_
      2 #define _GEOMETRY_TRIANGLE_HH_
      3 
      4 #include "all_includes.hh"
      5 
      6 class Triangle {
      7 private :
      8 	Vertex c[3];
      9 
     10 public :
     11 	Triangle();
     12 	Triangle(Vertex left, Vertex top, Vertex right);
     13 	inline Vertex& operator[] (SommetTriangle x) {
     14 		return c[x];
     15 	}
     16 	inline const Vertex& operator[] (SommetTriangle x) const {
     17 		return c[x];
     18 	}
     19 	inline Triangle operator>> (int rot) const {
     20 		return Triangle(c[LEFT - rot], c[TOP - rot], c[RIGHT - rot]);
     21 	}
     22 	inline Triangle operator<< (int rot) const {
     23 		return Triangle(c[LEFT + rot], c[TOP + rot], c[RIGHT + rot]);
     24 	}
     25 	friend Triangle operator+(const Triangle& t, const Vertex& v);
     26 	float cosAngle() const; // cosinus de l'angle en c[1].
     27 	float angle() const; // angle en c[TOP], en degrés.
     28 	float minAngle() const; // angle minimum du triangle (en LEFT, TOP ou RIGHT).
     29 	float maxAngle() const; // angle maximum du triangle (en LEFT, TOP ou RIGHT).
     30 	SommetTriangle minAngleCorner() const;
     31 	SommetTriangle maxAngleCorner() const;
     32 	float minLength() const;
     33 	float maxLength() const;
     34 	float surface() const;
     35 	Triangle inset(CoteTriangle side, float offset) const;
     36 	Triangle insetLTR(float offset) const;
     37 	Vertex randomPoint(int seed, int n) const;
     38 	Vertex normal() const;
     39 	Vertex normalizedNormal() const;
     40 	Triangle offsetNormal(float offset) const;
     41 	Triangle insetProportionnal(float prop);
     42 };
     43 
     44 class TriBool {
     45     private:
     46 	bool c[3];
     47 
     48     public :
     49 	TriBool();
     50 	TriBool(bool leftside, bool rightside, bool base) {
     51 		c[LEFTSIDE] = leftside;
     52 		c[RIGHTSIDE] = rightside;
     53 		c[BASE] = base;
     54 	};
     55 	inline bool& operator[] (CoteTriangle x) {
     56 		return c[x];
     57 	}
     58 	inline const bool& operator[] (CoteTriangle x) const {
     59 		return c[x];
     60 	}
     61 	inline TriBool operator>> (int rot) const {
     62 		return TriBool(c[LEFTSIDE - rot], c[RIGHTSIDE - rot], c[BASE - rot]);
     63 	}
     64 	inline TriBool operator<< (int rot) const {
     65 		return TriBool(c[LEFTSIDE + rot], c[RIGHTSIDE + rot], c[BASE + rot]);
     66 	}
     67 };
     68 
     69 #endif