Test du path finding

Dependencies:   RoboClaw mbed

Fork of TestMyPathFind by Romain Ame

Committer:
IceTeam
Date:
Wed Apr 13 16:17:19 2016 +0000
Revision:
41:53d5990ff99d
Parent:
39:ca4dd3faffa8
Correction odometrie;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IceTeam 39:ca4dd3faffa8 1 #include "obsCarr.h"
IceTeam 39:ca4dd3faffa8 2
IceTeam 39:ca4dd3faffa8 3 bool obsCarr::getCroisement (point A, point B) {
IceTeam 39:ca4dd3faffa8 4 point p0 (xcentre - dxtaille, ycentre + dytaille);
IceTeam 39:ca4dd3faffa8 5 point p1 (xcentre + dxtaille, ycentre + dytaille);
IceTeam 39:ca4dd3faffa8 6 point p2 (xcentre - dxtaille, ycentre - dytaille);
IceTeam 39:ca4dd3faffa8 7 point p3 (xcentre + dxtaille, ycentre - dytaille);
IceTeam 39:ca4dd3faffa8 8
IceTeam 39:ca4dd3faffa8 9 if (CroisementSegment (p0, p3, A, B) || CroisementSegment (p1, p2, A, B) || belongs(A) || belongs(B))
IceTeam 39:ca4dd3faffa8 10 return true;
IceTeam 39:ca4dd3faffa8 11 else
IceTeam 39:ca4dd3faffa8 12 return false;
IceTeam 39:ca4dd3faffa8 13 }
IceTeam 39:ca4dd3faffa8 14
IceTeam 39:ca4dd3faffa8 15 bool obsCarr::getCroisement (float X, float Y, point B) {
IceTeam 39:ca4dd3faffa8 16 point A (X, Y);
IceTeam 39:ca4dd3faffa8 17 return getCroisement (A, B);
IceTeam 39:ca4dd3faffa8 18 }
IceTeam 39:ca4dd3faffa8 19
IceTeam 39:ca4dd3faffa8 20 points4 obsCarr::getPoints () {
IceTeam 39:ca4dd3faffa8 21 return {
IceTeam 39:ca4dd3faffa8 22 point (xcentre - (dxtaille + MINDISTROBOT), ycentre + (dytaille + MINDISTROBOT)),
IceTeam 39:ca4dd3faffa8 23 point (xcentre + (dxtaille + MINDISTROBOT), ycentre + (dytaille + MINDISTROBOT)),
IceTeam 39:ca4dd3faffa8 24 point (xcentre - (dxtaille + MINDISTROBOT), ycentre - (dytaille + MINDISTROBOT)),
IceTeam 39:ca4dd3faffa8 25 point (xcentre + (dxtaille + MINDISTROBOT), ycentre - (dytaille + MINDISTROBOT)),
IceTeam 39:ca4dd3faffa8 26 };
IceTeam 39:ca4dd3faffa8 27 }
IceTeam 39:ca4dd3faffa8 28
IceTeam 39:ca4dd3faffa8 29 bool obsCarr::belongs (point& A) {
IceTeam 39:ca4dd3faffa8 30 return (A.getX () <= xcentre + dxtaille && A.getX () >= xcentre - dxtaille && A.getY () <= ycentre + dytaille && A.getY () >= ycentre - dytaille);
IceTeam 39:ca4dd3faffa8 31 }