Romain Ame
/
Stressed
coucou
Fork of Robot2016_2-0 by
Map/figure.h@46:be4eebf40568, 2016-04-25 (annotated)
- Committer:
- IceTeam
- Date:
- Mon Apr 25 12:42:32 2016 +0000
- Revision:
- 46:be4eebf40568
Petit commit de batard;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IceTeam | 46:be4eebf40568 | 1 | #ifndef FIGURE_H |
IceTeam | 46:be4eebf40568 | 2 | #define FIGURE_H |
IceTeam | 46:be4eebf40568 | 3 | |
IceTeam | 46:be4eebf40568 | 4 | #include "point.h" |
IceTeam | 46:be4eebf40568 | 5 | |
IceTeam | 46:be4eebf40568 | 6 | class figure { |
IceTeam | 46:be4eebf40568 | 7 | public: |
IceTeam | 46:be4eebf40568 | 8 | figure(float xc, float yc) { |
IceTeam | 46:be4eebf40568 | 9 | xcentre = xc; |
IceTeam | 46:be4eebf40568 | 10 | ycentre = yc; |
IceTeam | 46:be4eebf40568 | 11 | } |
IceTeam | 46:be4eebf40568 | 12 | |
IceTeam | 46:be4eebf40568 | 13 | float getX () { return xcentre; } |
IceTeam | 46:be4eebf40568 | 14 | float getY () { return ycentre; } |
IceTeam | 46:be4eebf40568 | 15 | |
IceTeam | 46:be4eebf40568 | 16 | bool CroisementSegment (point A1, point A2, point B1, point B2) { |
IceTeam | 46:be4eebf40568 | 17 | if (ProdVect (A1, A2, B1, B2) != 0) { // On verifie que les droites ne sont pas parallèles |
IceTeam | 46:be4eebf40568 | 18 | if (ProdVect (A1, A2, A1, B2)*ProdVect (A1, A2, A1, B1) <= 0 |
IceTeam | 46:be4eebf40568 | 19 | && ProdVect (B1, B2, B1, A1)*ProdVect (B1, B2, B1, A2) <= 0) { |
IceTeam | 46:be4eebf40568 | 20 | return true; |
IceTeam | 46:be4eebf40568 | 21 | } |
IceTeam | 46:be4eebf40568 | 22 | else { |
IceTeam | 46:be4eebf40568 | 23 | return false; |
IceTeam | 46:be4eebf40568 | 24 | } |
IceTeam | 46:be4eebf40568 | 25 | } |
IceTeam | 46:be4eebf40568 | 26 | else { |
IceTeam | 46:be4eebf40568 | 27 | return false; |
IceTeam | 46:be4eebf40568 | 28 | } |
IceTeam | 46:be4eebf40568 | 29 | } |
IceTeam | 46:be4eebf40568 | 30 | |
IceTeam | 46:be4eebf40568 | 31 | protected: |
IceTeam | 46:be4eebf40568 | 32 | float xcentre, ycentre; |
IceTeam | 46:be4eebf40568 | 33 | |
IceTeam | 46:be4eebf40568 | 34 | float ProdVect (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { |
IceTeam | 46:be4eebf40568 | 35 | return ((x2 - x1)*(y4 - y3) - (y2 - y1)*(x4 - x3)); |
IceTeam | 46:be4eebf40568 | 36 | } |
IceTeam | 46:be4eebf40568 | 37 | float ProdVect (point A1, point A2, point B1, point B2) { |
IceTeam | 46:be4eebf40568 | 38 | return ProdVect (A1.getX(), A1.getY (), A2.getX (), A2.getY (), B1.getX (), B1.getY (), B2.getX (), B2.getY ()); |
IceTeam | 46:be4eebf40568 | 39 | } |
IceTeam | 46:be4eebf40568 | 40 | }; |
IceTeam | 46:be4eebf40568 | 41 | #endif |