Romain Ame
/
Stressed
coucou
Fork of Robot2016_2-0 by
Map/point.h@46:be4eebf40568, 2016-04-25 (annotated)
- Committer:
- IceTeam
- Date:
- Mon Apr 25 12:42:32 2016 +0000
- Revision:
- 46:be4eebf40568
Petit commit de batard;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IceTeam | 46:be4eebf40568 | 1 | #ifndef POINT_H |
IceTeam | 46:be4eebf40568 | 2 | #define POINT_H |
IceTeam | 46:be4eebf40568 | 3 | |
IceTeam | 46:be4eebf40568 | 4 | typedef struct P4 points4; |
IceTeam | 46:be4eebf40568 | 5 | |
IceTeam | 46:be4eebf40568 | 6 | class point { |
IceTeam | 46:be4eebf40568 | 7 | public: |
IceTeam | 46:be4eebf40568 | 8 | point (float nx, float ny) { |
IceTeam | 46:be4eebf40568 | 9 | x = nx; |
IceTeam | 46:be4eebf40568 | 10 | y = ny; |
IceTeam | 46:be4eebf40568 | 11 | } |
IceTeam | 46:be4eebf40568 | 12 | point () { ; } |
IceTeam | 46:be4eebf40568 | 13 | |
IceTeam | 46:be4eebf40568 | 14 | float getX () { return x; } |
IceTeam | 46:be4eebf40568 | 15 | float getY () { return y; } |
IceTeam | 46:be4eebf40568 | 16 | void setX(float nx) { x = nx; } |
IceTeam | 46:be4eebf40568 | 17 | void setY(float ny) { y = ny; } |
IceTeam | 46:be4eebf40568 | 18 | |
IceTeam | 46:be4eebf40568 | 19 | float operator*(point& a) { |
IceTeam | 46:be4eebf40568 | 20 | return calculDistance2 (x, y, a.getX(), a.getY ()); |
IceTeam | 46:be4eebf40568 | 21 | } |
IceTeam | 46:be4eebf40568 | 22 | bool operator==(point& a) { |
IceTeam | 46:be4eebf40568 | 23 | return (x == a.getX () && y == a.getY ()); |
IceTeam | 46:be4eebf40568 | 24 | } |
IceTeam | 46:be4eebf40568 | 25 | bool operator!=(point& a) { |
IceTeam | 46:be4eebf40568 | 26 | return !(*this == a); |
IceTeam | 46:be4eebf40568 | 27 | } |
IceTeam | 46:be4eebf40568 | 28 | |
IceTeam | 46:be4eebf40568 | 29 | protected: |
IceTeam | 46:be4eebf40568 | 30 | float calculDistance2(float x1, float y1, float x2, float y2) { |
IceTeam | 46:be4eebf40568 | 31 | return ((x1-x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); |
IceTeam | 46:be4eebf40568 | 32 | } |
IceTeam | 46:be4eebf40568 | 33 | |
IceTeam | 46:be4eebf40568 | 34 | float x, y; |
IceTeam | 46:be4eebf40568 | 35 | }; |
IceTeam | 46:be4eebf40568 | 36 | |
IceTeam | 46:be4eebf40568 | 37 | struct P4 { |
IceTeam | 46:be4eebf40568 | 38 | point p0; |
IceTeam | 46:be4eebf40568 | 39 | point p1; |
IceTeam | 46:be4eebf40568 | 40 | point p2; |
IceTeam | 46:be4eebf40568 | 41 | point p3; |
IceTeam | 46:be4eebf40568 | 42 | }; |
IceTeam | 46:be4eebf40568 | 43 | |
IceTeam | 46:be4eebf40568 | 44 | #endif |