Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Timer by
Map/figure.h@47:be4eebf40568, 2016-04-25 (annotated)
- Committer:
- IceTeam
- Date:
- Mon Apr 25 12:42:32 2016 +0000
- Revision:
- 47:be4eebf40568
Petit commit de batard;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| IceTeam | 47:be4eebf40568 | 1 | #ifndef FIGURE_H |
| IceTeam | 47:be4eebf40568 | 2 | #define FIGURE_H |
| IceTeam | 47:be4eebf40568 | 3 | |
| IceTeam | 47:be4eebf40568 | 4 | #include "point.h" |
| IceTeam | 47:be4eebf40568 | 5 | |
| IceTeam | 47:be4eebf40568 | 6 | class figure { |
| IceTeam | 47:be4eebf40568 | 7 | public: |
| IceTeam | 47:be4eebf40568 | 8 | figure(float xc, float yc) { |
| IceTeam | 47:be4eebf40568 | 9 | xcentre = xc; |
| IceTeam | 47:be4eebf40568 | 10 | ycentre = yc; |
| IceTeam | 47:be4eebf40568 | 11 | } |
| IceTeam | 47:be4eebf40568 | 12 | |
| IceTeam | 47:be4eebf40568 | 13 | float getX () { return xcentre; } |
| IceTeam | 47:be4eebf40568 | 14 | float getY () { return ycentre; } |
| IceTeam | 47:be4eebf40568 | 15 | |
| IceTeam | 47:be4eebf40568 | 16 | bool CroisementSegment (point A1, point A2, point B1, point B2) { |
| IceTeam | 47:be4eebf40568 | 17 | if (ProdVect (A1, A2, B1, B2) != 0) { // On verifie que les droites ne sont pas parallèles |
| IceTeam | 47:be4eebf40568 | 18 | if (ProdVect (A1, A2, A1, B2)*ProdVect (A1, A2, A1, B1) <= 0 |
| IceTeam | 47:be4eebf40568 | 19 | && ProdVect (B1, B2, B1, A1)*ProdVect (B1, B2, B1, A2) <= 0) { |
| IceTeam | 47:be4eebf40568 | 20 | return true; |
| IceTeam | 47:be4eebf40568 | 21 | } |
| IceTeam | 47:be4eebf40568 | 22 | else { |
| IceTeam | 47:be4eebf40568 | 23 | return false; |
| IceTeam | 47:be4eebf40568 | 24 | } |
| IceTeam | 47:be4eebf40568 | 25 | } |
| IceTeam | 47:be4eebf40568 | 26 | else { |
| IceTeam | 47:be4eebf40568 | 27 | return false; |
| IceTeam | 47:be4eebf40568 | 28 | } |
| IceTeam | 47:be4eebf40568 | 29 | } |
| IceTeam | 47:be4eebf40568 | 30 | |
| IceTeam | 47:be4eebf40568 | 31 | protected: |
| IceTeam | 47:be4eebf40568 | 32 | float xcentre, ycentre; |
| IceTeam | 47:be4eebf40568 | 33 | |
| IceTeam | 47:be4eebf40568 | 34 | float ProdVect (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { |
| IceTeam | 47:be4eebf40568 | 35 | return ((x2 - x1)*(y4 - y3) - (y2 - y1)*(x4 - x3)); |
| IceTeam | 47:be4eebf40568 | 36 | } |
| IceTeam | 47:be4eebf40568 | 37 | float ProdVect (point A1, point A2, point B1, point B2) { |
| IceTeam | 47:be4eebf40568 | 38 | return ProdVect (A1.getX(), A1.getY (), A2.getX (), A2.getY (), B1.getX (), B1.getY (), B2.getX (), B2.getY ()); |
| IceTeam | 47:be4eebf40568 | 39 | } |
| IceTeam | 47:be4eebf40568 | 40 | }; |
| IceTeam | 47:be4eebf40568 | 41 | #endif |
