summaryrefslogtreecommitdiffstats
path: root/Triangle.h
blob: a3c8aa89f25e0d92183ac19eeed9baf29c4bc559 (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
36
37
38
39
40
41
42
#ifndef TRIANGLE_H_
#define TRIANGLE_H_


#include "Vertex.h"
#include "Line.h"

class Triangle {
  private:
    Vertex va, vb, vc;
  public:
    enum Direction {
      CW, CCW, UNKNOWN
    };
        
    Triangle() {}
    Triangle(const Vertex& vertexa, const Vertex& vertexb, const Vertex& vertexc)
      : va(vertexa), vb(vertexb), vc(vertexc) {}
    
    Vertex &getVertexA() {return va;}
    const Vertex &getVertexA() const {return va;}
    void setVertexA(const Vertex &v) {va = v;}
    
    Vertex &getVertexB() {return vb;}
    const Vertex &getVertexB() const {return vb;}
    void setVertexB(const Vertex &v) {vb = v;}
    
    Vertex &getVertexC() {return vc;}
    const Vertex &getVertexC() const {return vc;}
    void setVertexC(const Vertex &v) {vc = v;}
    
    Direction getDirection() const;
    
    float area() const;
    float perimeter() const;
    
    bool contains(const Vertex &v) const;
    bool onEdge(const Vertex &v) const;
    int intersectionCount(const Line &l) const;
};

#endif /*TRIANGLE_H_*/