quickhull/Point.h

55 lines
896 B
C++

#ifndef POINT_H
#define POINT_H
class Point
{
private:
float m_x, m_y;
public:
Point(float x, float y) : m_x(x), m_y(y) {}
Point() : m_x(0), m_y(0) {}
float x() const
{
return m_x;
}
float y() const
{
return m_y;
}
Point operator+(const Point &other) const
{
return Point(x() + other.x(), y() + other.y());
}
Point operator-(const Point &other) const
{
return Point(x() - other.x(), y() - other.y());
}
Point &operator+=(const Point &other)
{
m_x += other.x();
m_y += other.y();
return *this;
}
Point &operator-=(const Point &other)
{
m_x -= other.x();
m_y -= other.y();
return *this;
}
bool operator==(const Point &other) const
{
return (x() == other.x() && y() == other.y());
}
};
#endif // POINT_H