generate-shapes/src/util/geo/Point.h

46 lines
944 B
C
Raw Normal View History

2018-07-06 16:22:06 +02:00
// Copyright 2016, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#ifndef UTIL_GEO_POINT_H_
#define UTIL_GEO_POINT_H_
namespace util {
2018-07-12 14:23:29 +02:00
namespace geo {
2018-07-06 16:22:06 +02:00
template <typename T>
class Point {
public:
2018-07-15 14:13:31 +02:00
Point() : _x(0), _y(0) {}
2018-07-06 16:22:06 +02:00
Point(T x, T y) : _x(x), _y(y) {}
T getX() const { return _x; }
T getY() const { return _y; }
void setX(T x) { _x = x; }
void setY(T y) { _y = y; }
2018-07-10 17:04:59 +02:00
Point<T> operator+(const Point<T>& p) const {
return Point<T>(_x + p.getX(), _y + p.getY());
}
2018-07-18 19:26:34 +02:00
Point<T> operator-(const Point<T>& p) const {
return Point<T>(_x - p.getX(), _y - p.getY());
}
2018-07-10 17:04:59 +02:00
bool operator==(const Point<T>& p) const {
return p.getX() == _x && p.getY() == _y;
}
bool operator!=(const Point<T>& p) const {
return !(*this == p);
}
2018-07-06 16:22:06 +02:00
private:
T _x, _y;
};
2018-07-12 14:23:29 +02:00
} // namespace geo
2018-07-06 16:22:06 +02:00
} // namespace util
#endif // UTIL_GEO_POINT_H_