#include "Vertex.h" #include float Vertex::distanceSq(const Vertex &v) const { return (x - v.x)*(x - v.x) + (y - v.y)*(y - v.y); } float Vertex::distance(const Vertex &v) const { return sqrtf(distanceSq(v)); } Vertex Vertex::operator+(const Vertex &v) const { return Vertex(x + v.x, y + v.y); } Vertex Vertex::operator-(const Vertex &v) const { return Vertex(x - v.x, y - v.y); } Vertex Vertex::operator*(float f) const { return Vertex(x*f, y*f); } Vertex Vertex::operator/(float f) const { return Vertex(x/f, y/f); } Vertex& Vertex::operator+=(const Vertex &v) { x += v.x; y += v.y; return *this; } Vertex& Vertex::operator-=(const Vertex &v) { x -= v.x; y -= v.y; return *this; } Vertex& Vertex::operator*=(float f) { x *= f; y *= f; return *this; } Vertex& Vertex::operator/=(float f) { x /= f; y /= f; return *this; }