Test du path finding

Dependencies:   RoboClaw mbed

Fork of TestMyPathFind by Romain Ame

Committer:
IceTeam
Date:
Wed Apr 13 11:27:01 2016 +0000
Revision:
39:ca4dd3faffa8
First publish;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IceTeam 39:ca4dd3faffa8 1 #ifndef POINT_H
IceTeam 39:ca4dd3faffa8 2 #define POINT_H
IceTeam 39:ca4dd3faffa8 3
IceTeam 39:ca4dd3faffa8 4 typedef struct P4 points4;
IceTeam 39:ca4dd3faffa8 5
IceTeam 39:ca4dd3faffa8 6 class point {
IceTeam 39:ca4dd3faffa8 7 public:
IceTeam 39:ca4dd3faffa8 8 point (float nx, float ny) {
IceTeam 39:ca4dd3faffa8 9 x = nx;
IceTeam 39:ca4dd3faffa8 10 y = ny;
IceTeam 39:ca4dd3faffa8 11 }
IceTeam 39:ca4dd3faffa8 12 point () { ; }
IceTeam 39:ca4dd3faffa8 13
IceTeam 39:ca4dd3faffa8 14 float getX () { return x; }
IceTeam 39:ca4dd3faffa8 15 float getY () { return y; }
IceTeam 39:ca4dd3faffa8 16
IceTeam 39:ca4dd3faffa8 17 float operator*(point& a) {
IceTeam 39:ca4dd3faffa8 18 return calculDistance2 (x, y, a.getX(), a.getY ());
IceTeam 39:ca4dd3faffa8 19 }
IceTeam 39:ca4dd3faffa8 20 bool operator==(point& a) {
IceTeam 39:ca4dd3faffa8 21 return (x == a.getX () && y == a.getY ());
IceTeam 39:ca4dd3faffa8 22 }
IceTeam 39:ca4dd3faffa8 23 bool operator!=(point& a) {
IceTeam 39:ca4dd3faffa8 24 return !(*this == a);
IceTeam 39:ca4dd3faffa8 25 }
IceTeam 39:ca4dd3faffa8 26
IceTeam 39:ca4dd3faffa8 27 protected:
IceTeam 39:ca4dd3faffa8 28 float calculDistance2(float x1, float y1, float x2, float y2) {
IceTeam 39:ca4dd3faffa8 29 return ((x1-x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
IceTeam 39:ca4dd3faffa8 30 }
IceTeam 39:ca4dd3faffa8 31
IceTeam 39:ca4dd3faffa8 32 float x, y;
IceTeam 39:ca4dd3faffa8 33 };
IceTeam 39:ca4dd3faffa8 34
IceTeam 39:ca4dd3faffa8 35 struct P4 {
IceTeam 39:ca4dd3faffa8 36 point p0;
IceTeam 39:ca4dd3faffa8 37 point p1;
IceTeam 39:ca4dd3faffa8 38 point p2;
IceTeam 39:ca4dd3faffa8 39 point p3;
IceTeam 39:ca4dd3faffa8 40 };
IceTeam 39:ca4dd3faffa8 41
IceTeam 39:ca4dd3faffa8 42 #endif