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