summaryrefslogtreecommitdiffstats
path: root/Vertex.h
blob: 5f0db76a8bb3890d9ab7f1f66626bf00033f2f19 (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
32
33
34
35
#ifndef VERTEX_H_
#define VERTEX_H_

class Vertex {
  private:
    float x, y;
    
  public:
    Vertex() {x = y = 0.0;}
    Vertex(float x, float y) {this->x = x; this->y = y;}
    
    float getX() const {return x;}
    void setX(float x) {this->x = x;}
    
    float getY() const {return y;}
    void setY(float y) {this->y = y;}
    
    void setLocation(float x, float y) {this->x = x; this->y = y;}
    
    float distanceSq(const Vertex &v) const;
    float distance(const Vertex &v) const;
    
    Vertex operator+(const Vertex &v) const;
    Vertex operator-(const Vertex &v) const;
    Vertex operator*(float f) const;
    Vertex operator/(float f) const;
    
    Vertex& operator+=(const Vertex &v);
    Vertex& operator-=(const Vertex &v);
    Vertex& operator*=(float f);
    Vertex& operator/=(float f);
        
};

#endif /*VERTEX_H_*/