ARES
/
TestMyPathFind
Test du path finding
Fork of TestMyPathFind by
map/pointParcours.h@41:53d5990ff99d, 2016-04-13 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
IceTeam | 39:ca4dd3faffa8 | 1 | #ifndef POINTPARCOURS_H |
IceTeam | 39:ca4dd3faffa8 | 2 | #define POINTPARCOURS_H |
IceTeam | 39:ca4dd3faffa8 | 3 | #include "math.h" |
IceTeam | 39:ca4dd3faffa8 | 4 | |
IceTeam | 39:ca4dd3faffa8 | 5 | #include "controle.h" |
IceTeam | 39:ca4dd3faffa8 | 6 | #include "point.h" |
IceTeam | 39:ca4dd3faffa8 | 7 | |
IceTeam | 39:ca4dd3faffa8 | 8 | typedef struct PP4 PointsParc4; |
IceTeam | 39:ca4dd3faffa8 | 9 | |
IceTeam | 39:ca4dd3faffa8 | 10 | class pointParcours : public point { |
IceTeam | 39:ca4dd3faffa8 | 11 | public: |
IceTeam | 39:ca4dd3faffa8 | 12 | pointParcours (float nx, float ny, pointParcours * npere, point *arr) : point (nx, ny) { |
IceTeam | 39:ca4dd3faffa8 | 13 | if (npere != NULL) |
IceTeam | 39:ca4dd3faffa8 | 14 | G2 = sqrt(npere->getG2() + calculDistance2 (nx, ny, npere->getX(), npere->getY ())); |
IceTeam | 39:ca4dd3faffa8 | 15 | else |
IceTeam | 39:ca4dd3faffa8 | 16 | G2 = 0; |
IceTeam | 39:ca4dd3faffa8 | 17 | pere = npere; |
IceTeam | 39:ca4dd3faffa8 | 18 | H2 = sqrt (calculDistance2 (nx, ny, arr->getX (), arr->getY ())); |
IceTeam | 39:ca4dd3faffa8 | 19 | } |
IceTeam | 39:ca4dd3faffa8 | 20 | |
IceTeam | 39:ca4dd3faffa8 | 21 | pointParcours (point p, pointParcours * npere, point *arr) : point (p) { |
IceTeam | 39:ca4dd3faffa8 | 22 | if (pere != NULL) |
IceTeam | 39:ca4dd3faffa8 | 23 | G2 = npere->getG2 () + calculDistance2 (p.getX(), p.getY(), npere->getX (), npere->getY ()); |
IceTeam | 39:ca4dd3faffa8 | 24 | else |
IceTeam | 39:ca4dd3faffa8 | 25 | G2 = 0; |
IceTeam | 39:ca4dd3faffa8 | 26 | pere = npere; |
IceTeam | 39:ca4dd3faffa8 | 27 | |
IceTeam | 39:ca4dd3faffa8 | 28 | H2 = sqrt(calculDistance2 (p.getX (), p.getY (), arr->getX (), arr->getY ())); |
IceTeam | 39:ca4dd3faffa8 | 29 | } |
IceTeam | 39:ca4dd3faffa8 | 30 | |
IceTeam | 39:ca4dd3faffa8 | 31 | pointParcours * getPere () { return pere; } |
IceTeam | 39:ca4dd3faffa8 | 32 | |
IceTeam | 39:ca4dd3faffa8 | 33 | long double getG2 () { return G2; } |
IceTeam | 39:ca4dd3faffa8 | 34 | long double getH2 () { return H2; } |
IceTeam | 39:ca4dd3faffa8 | 35 | long double getP2 () { return G2 + H2; } |
IceTeam | 39:ca4dd3faffa8 | 36 | |
IceTeam | 39:ca4dd3faffa8 | 37 | bool operator==(pointParcours& a) { |
IceTeam | 39:ca4dd3faffa8 | 38 | // Autre version : return (x == a.getX () && y == a.getY () && a.getP2 () == G2 + H2); |
IceTeam | 39:ca4dd3faffa8 | 39 | return (x == a.getX () && y == a.getY ()); |
IceTeam | 39:ca4dd3faffa8 | 40 | } |
IceTeam | 39:ca4dd3faffa8 | 41 | |
IceTeam | 39:ca4dd3faffa8 | 42 | bool operator==(point& a) { |
IceTeam | 39:ca4dd3faffa8 | 43 | return (x == a.getX () && y == a.getY ()); |
IceTeam | 39:ca4dd3faffa8 | 44 | } |
IceTeam | 39:ca4dd3faffa8 | 45 | |
IceTeam | 39:ca4dd3faffa8 | 46 | protected: |
IceTeam | 39:ca4dd3faffa8 | 47 | pointParcours * pere; |
IceTeam | 39:ca4dd3faffa8 | 48 | long double G2, H2; |
IceTeam | 39:ca4dd3faffa8 | 49 | }; |
IceTeam | 39:ca4dd3faffa8 | 50 | |
IceTeam | 39:ca4dd3faffa8 | 51 | struct PP4 { |
IceTeam | 39:ca4dd3faffa8 | 52 | pointParcours p0; |
IceTeam | 39:ca4dd3faffa8 | 53 | pointParcours p1; |
IceTeam | 39:ca4dd3faffa8 | 54 | pointParcours p2; |
IceTeam | 39:ca4dd3faffa8 | 55 | pointParcours p3; |
IceTeam | 39:ca4dd3faffa8 | 56 | }; |
IceTeam | 39:ca4dd3faffa8 | 57 | |
IceTeam | 39:ca4dd3faffa8 | 58 | #endif |