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 #ifndef FIGURE_H
IceTeam 39:ca4dd3faffa8 2 #define FIGURE_H
IceTeam 39:ca4dd3faffa8 3
IceTeam 39:ca4dd3faffa8 4 #include "point.h"
IceTeam 39:ca4dd3faffa8 5
IceTeam 39:ca4dd3faffa8 6 class figure {
IceTeam 39:ca4dd3faffa8 7 public:
IceTeam 39:ca4dd3faffa8 8 figure(float xc, float yc) {
IceTeam 39:ca4dd3faffa8 9 xcentre = xc;
IceTeam 39:ca4dd3faffa8 10 ycentre = yc;
IceTeam 39:ca4dd3faffa8 11 }
IceTeam 39:ca4dd3faffa8 12
IceTeam 39:ca4dd3faffa8 13 float getX () { return xcentre; }
IceTeam 39:ca4dd3faffa8 14 float getY () { return ycentre; }
IceTeam 39:ca4dd3faffa8 15
IceTeam 39:ca4dd3faffa8 16 bool CroisementSegment (point A1, point A2, point B1, point B2) {
IceTeam 39:ca4dd3faffa8 17 if (ProdVect (A1, A2, B1, B2) != 0) { // On verifie que les droites ne sont pas parallèles
IceTeam 39:ca4dd3faffa8 18 if (ProdVect (A1, A2, A1, B2)*ProdVect (A1, A2, A1, B1) <= 0
IceTeam 39:ca4dd3faffa8 19 && ProdVect (B1, B2, B1, A1)*ProdVect (B1, B2, B1, A2) <= 0) {
IceTeam 39:ca4dd3faffa8 20 return true;
IceTeam 39:ca4dd3faffa8 21 }
IceTeam 39:ca4dd3faffa8 22 else {
IceTeam 39:ca4dd3faffa8 23 return false;
IceTeam 39:ca4dd3faffa8 24 }
IceTeam 39:ca4dd3faffa8 25 }
IceTeam 39:ca4dd3faffa8 26 else {
IceTeam 39:ca4dd3faffa8 27 return false;
IceTeam 39:ca4dd3faffa8 28 }
IceTeam 39:ca4dd3faffa8 29 }
IceTeam 39:ca4dd3faffa8 30
IceTeam 39:ca4dd3faffa8 31 protected:
IceTeam 39:ca4dd3faffa8 32 float xcentre, ycentre;
IceTeam 39:ca4dd3faffa8 33
IceTeam 39:ca4dd3faffa8 34 float ProdVect (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
IceTeam 39:ca4dd3faffa8 35 return ((x2 - x1)*(y4 - y3) - (y2 - y1)*(x4 - x3));
IceTeam 39:ca4dd3faffa8 36 }
IceTeam 39:ca4dd3faffa8 37 float ProdVect (point A1, point A2, point B1, point B2) {
IceTeam 39:ca4dd3faffa8 38 return ProdVect (A1.getX(), A1.getY (), A2.getX (), A2.getY (), B1.getX (), B1.getY (), B2.getX (), B2.getY ());
IceTeam 39:ca4dd3faffa8 39 }
IceTeam 39:ca4dd3faffa8 40 };
IceTeam 39:ca4dd3faffa8 41 #endif