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.
Dependencies: RoboClaw StepperMotor mbed
Fork of Robot2016_2-0 by
Map/Obstacles/Obs_circle.cpp@11:9c70a7f4d7aa, 2016-01-05 (annotated)
- Committer:
- IceTeam
- Date:
- Tue Jan 05 15:48:25 2016 +0100
- Revision:
- 11:9c70a7f4d7aa
Ajout du fichier parent
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| IceTeam | 11:9c70a7f4d7aa | 1 | #include "Obs_circle.h" |
| IceTeam | 11:9c70a7f4d7aa | 2 | |
| IceTeam | 11:9c70a7f4d7aa | 3 | Obs_circle::Obs_circle(float robotRadius, int id, float x, float y, float size):Obstacle(robotRadius,id) |
| IceTeam | 11:9c70a7f4d7aa | 4 | { |
| IceTeam | 11:9c70a7f4d7aa | 5 | this->x = x; |
| IceTeam | 11:9c70a7f4d7aa | 6 | this->y = y; |
| IceTeam | 11:9c70a7f4d7aa | 7 | this->size2 = size*size; |
| IceTeam | 11:9c70a7f4d7aa | 8 | } |
| IceTeam | 11:9c70a7f4d7aa | 9 | |
| IceTeam | 11:9c70a7f4d7aa | 10 | int Obs_circle::height(float x, float y) |
| IceTeam | 11:9c70a7f4d7aa | 11 | { |
| IceTeam | 11:9c70a7f4d7aa | 12 | if(!active) |
| IceTeam | 11:9c70a7f4d7aa | 13 | return 0; |
| IceTeam | 11:9c70a7f4d7aa | 14 | |
| IceTeam | 11:9c70a7f4d7aa | 15 | float d = (x-this->x)*(x-this->x) + (y-this->y)*(y-this->y); |
| IceTeam | 11:9c70a7f4d7aa | 16 | if(d <= size2) // On est dans le cercle |
| IceTeam | 11:9c70a7f4d7aa | 17 | { |
| IceTeam | 11:9c70a7f4d7aa | 18 | return 32000; // Interdit |
| IceTeam | 11:9c70a7f4d7aa | 19 | } |
| IceTeam | 11:9c70a7f4d7aa | 20 | else if(bigShape && d <= size2+robotRadius*robotRadius) // On est dans le grand cercle |
| IceTeam | 11:9c70a7f4d7aa | 21 | { |
| IceTeam | 11:9c70a7f4d7aa | 22 | if(!smoothBigShape) |
| IceTeam | 11:9c70a7f4d7aa | 23 | return 32000; // Interdit |
| IceTeam | 11:9c70a7f4d7aa | 24 | else |
| IceTeam | 11:9c70a7f4d7aa | 25 | { |
| IceTeam | 11:9c70a7f4d7aa | 26 | return 32000; // Interdit |
| IceTeam | 11:9c70a7f4d7aa | 27 | } |
| IceTeam | 11:9c70a7f4d7aa | 28 | } |
| IceTeam | 11:9c70a7f4d7aa | 29 | return 0; |
| IceTeam | 11:9c70a7f4d7aa | 30 | } |
