summaryrefslogtreecommitdiffstats
path: root/Vertex.h
blob: e7d47cee28edc491b9941016135072bc455cf282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#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_*/