Romain Ame / Mbed 2 deprecated Robot2016_2-0_STATIC

Dependencies:   RoboClaw StepperMotor mbed

Fork of Robot2016_2-0 by ARES

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pointParcours.h Source File

pointParcours.h

00001 #ifndef POINTPARCOURS_H
00002 #define POINTPARCOURS_H
00003 #include "math.h"
00004 
00005 #include "controle.h"
00006 #include "point.h"
00007 
00008 typedef struct PP4 PointsParc4;
00009 
00010 class pointParcours : public point {
00011 public:
00012     pointParcours (float nx, float ny, pointParcours * npere, point arr) : point (nx, ny) {
00013         if (npere != NULL)
00014             G2 = sqrt(npere->getG2() + calculDistance2 (nx, ny, npere->getX(), npere->getY ()));
00015         else
00016             G2 = 0;
00017         pere = npere;
00018         H2 = sqrt (calculDistance2 (nx, ny, arr.getX (), arr.getY ()));
00019     }
00020 
00021     pointParcours (point p, pointParcours * npere, point arr) : point (p) {
00022         if (pere != NULL)
00023             G2 = npere->getG2 () + calculDistance2 (p.getX(), p.getY(), npere->getX (), npere->getY ());
00024         else
00025             G2 = 0;
00026         pere = npere;
00027 
00028         H2 = sqrt(calculDistance2 (p.getX (), p.getY (), arr.getX (), arr.getY ()));
00029     }
00030 
00031     pointParcours * getPere () { return pere; }
00032 
00033     long double getG2 () { return G2; }
00034     long double getH2 () { return H2; }
00035     long double getP2 () { return G2 + H2; }
00036 
00037     bool operator==(pointParcours& a) {
00038         // Autre version : return (x == a.getX () && y == a.getY () && a.getP2 () == G2 + H2);
00039         return (x == a.getX () && y == a.getY ());
00040     }
00041 
00042     bool operator==(point& a) {
00043         return (x == a.getX () && y == a.getY ());
00044     }
00045 
00046 protected:
00047     pointParcours * pere;
00048     long double G2, H2;
00049 };
00050 
00051 struct PP4 {
00052     pointParcours p0;
00053     pointParcours p1;
00054     pointParcours p2;
00055     pointParcours p3;
00056 };
00057 
00058 #endif