This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
neofx-zoomedit/Vertex.cpp
2007-09-16 14:07:03 +00:00

33 lines
587 B
C++

#include "Vertex.h"
#include <math.h>
double Vertex::distanceSq(const Vertex &v) const {
return (x - v.x)*(x - v.x) + (y - v.y)*(y - v.y);
}
double Vertex::distance(const Vertex &v) const {
return sqrt(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+=(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;
}