quad.hh (2144B)
1 #ifndef _GEOMETRY_QUAD_HH_ 2 #define _GEOMETRY_QUAD_HH_ 3 4 #include "all_includes.hh" 5 6 // Quad est un quadrilatère 7 class Quad { 8 private: 9 Vertex c[4]; 10 11 public : 12 Quad(); 13 Quad(Vertex ne, Vertex se, Vertex sw, Vertex nw); 14 inline Vertex& operator[] (Coin x) { 15 return c[x]; 16 } 17 inline const Vertex& operator[] (Coin x) const { 18 return c[x]; 19 } 20 inline Quad operator>> (int rot) const { 21 return Quad(c[NE - rot], c[SE - rot], c[SW - rot], c[NW - rot]); 22 } 23 inline Quad operator<< (int rot) const { 24 return Quad(c[NE + rot], c[SE + rot], c[SW + rot], c[NW + rot]); 25 } 26 friend Quad operator+(const Quad& t, const Vertex& v); 27 Quad inset(Cardinal side, float offset) const; 28 Quad insetNESW(float offsetN, float offsetE, float offsetS, float offsetW) const; 29 Quad insetNESW(float offset) const; 30 Quad insetOpp(Cardinal side, float offset) const; 31 float length(Cardinal side) const; 32 float minLengthNS() const; 33 float minLengthEW() const; 34 float maxLengthNS() const; 35 float maxLengthEW() const; 36 float minLength() const; 37 float maxLength() const; 38 Cardinal minLengthSide() const; 39 Cardinal maxLengthSide() const; 40 Coin concaveCorner(); 41 bool isConcave(); 42 float angle(Coin corner) const; 43 float minAngle() const; 44 float maxAngle() const; 45 Coin minAngleCorner() const; 46 Coin maxAngleCorner() const; 47 Vertex randomPoint(int seed, int n) const; 48 float surface() const; 49 //void cutCornerCorner(Coin from) const; 50 Quad makeParallelogram() const; 51 Quad insetProportionnal(float prop); 52 Quad offsetNormal(float offset) const; 53 Vertex normal() const; 54 Vertex normalizedNormal() const; 55 Vertex moyenne() const; 56 }; 57 58 class QuadBool { 59 private: 60 bool c[4]; 61 62 public : 63 QuadBool(); 64 QuadBool(bool n, bool e, bool s, bool w) { 65 c[N] = n; 66 c[E] = e; 67 c[S] = s; 68 c[W] = w; 69 }; 70 inline bool& operator[] (Cardinal x) { 71 return c[x]; 72 } 73 inline const bool& operator[] (Cardinal x) const { 74 return c[x]; 75 } 76 inline QuadBool operator>> (int rot) const { 77 return QuadBool(c[N - rot], c[E - rot], c[S - rot], c[N - rot]); 78 } 79 inline QuadBool operator<< (int rot) const { 80 return QuadBool(c[N + rot], c[E + rot], c[S + rot], c[W + rot]); 81 } 82 }; 83 84 #endif