31 lines
819 B
C++
31 lines
819 B
C++
#ifndef VERTEX_H_
|
|
#define VERTEX_H_
|
|
|
|
class Vertex {
|
|
private:
|
|
double x, y;
|
|
public:
|
|
Vertex() {x = y = 0.0;}
|
|
Vertex(const Vertex &v) {x = v.x; y = v.y;}
|
|
Vertex(double x, double y) {this->x = x; this->y = y;}
|
|
|
|
double getX() const {return x;}
|
|
void setX(double x) {this->x = x;}
|
|
|
|
double getY() const {return y;}
|
|
void setY(double y) {this->y = y;}
|
|
|
|
void setLocation(const Vertex &v) {x = v.x; y = v.y;}
|
|
void setLocation(double x, double y) {this->x = x; this->y = y;}
|
|
|
|
double distanceSq(const Vertex &v) const;
|
|
double distance(const Vertex &v) const;
|
|
|
|
Vertex operator+(const Vertex &v) const;
|
|
Vertex operator-(const Vertex &v) const;
|
|
|
|
Vertex& operator+=(const Vertex &v);
|
|
Vertex& operator-=(const Vertex &v);
|
|
};
|
|
|
|
#endif /*VERTEX_H_*/
|