33 lines
662 B
C++
33 lines
662 B
C++
#ifndef POINT2D_H
|
|
#define POINT2D_H
|
|
|
|
#include "Arduino.h"
|
|
|
|
class Point2D {
|
|
public:
|
|
Point2D() : x(0), y(0) {}
|
|
Point2D(uint16_t _x, uint16_t _y) : x(_x), y(_y) {}
|
|
|
|
virtual ~Point2D() {}
|
|
|
|
void setX(uint16_t _x) { x = _x; }
|
|
void setY(uint16_t _y) { y = _y; }
|
|
uint16_t getX() { return x; }
|
|
uint16_t getY() { return y; }
|
|
bool isOrigin() { return x == 0 && y == 0; }
|
|
|
|
bool operator==(const Point2D& other) {
|
|
return this->x == other.x && this->y == other.y;
|
|
}
|
|
|
|
bool operator!=(const Point2D other) {
|
|
return this->x != other.x || this->y != other.y;
|
|
}
|
|
|
|
private:
|
|
uint16_t
|
|
x,
|
|
y;
|
|
};
|
|
|
|
#endif |