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 Robot2016_2-0 by
Map/obsCarr.cpp@79:b11b50108ae5, 2016-05-05 (annotated)
- Committer:
- IceTeam
- Date:
- Thu May 05 15:11:06 2016 +0000
- Revision:
- 79:b11b50108ae5
- Parent:
- 47:be4eebf40568
Nicksamer;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| IceTeam | 47:be4eebf40568 | 1 | #include "obsCarr.h" |
| IceTeam | 47:be4eebf40568 | 2 | |
| IceTeam | 47:be4eebf40568 | 3 | bool obsCarr::getCroisement (point A, point B) { |
| IceTeam | 47:be4eebf40568 | 4 | point p0 (xcentre - dxtaille, ycentre + dytaille); |
| IceTeam | 47:be4eebf40568 | 5 | point p1 (xcentre + dxtaille, ycentre + dytaille); |
| IceTeam | 47:be4eebf40568 | 6 | point p2 (xcentre - dxtaille, ycentre - dytaille); |
| IceTeam | 47:be4eebf40568 | 7 | point p3 (xcentre + dxtaille, ycentre - dytaille); |
| IceTeam | 47:be4eebf40568 | 8 | |
| IceTeam | 47:be4eebf40568 | 9 | if (CroisementSegment (p0, p3, A, B) || CroisementSegment (p1, p2, A, B) || belongs(A) || belongs(B)) |
| IceTeam | 47:be4eebf40568 | 10 | return true; |
| IceTeam | 47:be4eebf40568 | 11 | else |
| IceTeam | 47:be4eebf40568 | 12 | return false; |
| IceTeam | 47:be4eebf40568 | 13 | } |
| IceTeam | 47:be4eebf40568 | 14 | |
| IceTeam | 47:be4eebf40568 | 15 | bool obsCarr::getCroisement (float X, float Y, point B) { |
| IceTeam | 47:be4eebf40568 | 16 | point A (X, Y); |
| IceTeam | 47:be4eebf40568 | 17 | return getCroisement (A, B); |
| IceTeam | 47:be4eebf40568 | 18 | } |
| IceTeam | 47:be4eebf40568 | 19 | |
| IceTeam | 47:be4eebf40568 | 20 | points4 obsCarr::getPoints () { |
| IceTeam | 47:be4eebf40568 | 21 | return { |
| IceTeam | 47:be4eebf40568 | 22 | point (xcentre - (dxtaille + MINDISTROBOT), ycentre + (dytaille + MINDISTROBOT)), |
| IceTeam | 47:be4eebf40568 | 23 | point (xcentre + (dxtaille + MINDISTROBOT), ycentre + (dytaille + MINDISTROBOT)), |
| IceTeam | 47:be4eebf40568 | 24 | point (xcentre - (dxtaille + MINDISTROBOT), ycentre - (dytaille + MINDISTROBOT)), |
| IceTeam | 47:be4eebf40568 | 25 | point (xcentre + (dxtaille + MINDISTROBOT), ycentre - (dytaille + MINDISTROBOT)), |
| IceTeam | 47:be4eebf40568 | 26 | }; |
| IceTeam | 47:be4eebf40568 | 27 | } |
| IceTeam | 47:be4eebf40568 | 28 | |
| IceTeam | 47:be4eebf40568 | 29 | bool obsCarr::belongs (point& A) { |
| IceTeam | 47:be4eebf40568 | 30 | return (A.getX () <= xcentre + dxtaille && A.getX () >= xcentre - dxtaille && A.getY () <= ycentre + dytaille && A.getY () >= ycentre - dytaille); |
| IceTeam | 47:be4eebf40568 | 31 | } |
