39 lines
709 B
C++
39 lines
709 B
C++
#ifndef TRIANGLE_H
|
|
#define TRIANGLE_H
|
|
|
|
#include "Point.h"
|
|
#include "Line.h"
|
|
|
|
class Triangle
|
|
{
|
|
private:
|
|
Point m_p1, m_p2, m_p3;
|
|
Line m_l1, m_l2, m_l3;
|
|
|
|
public:
|
|
// The points must come in __clockwise__ order.
|
|
Triangle(Point p1, Point p2, Point p3)
|
|
: m_p1(p1), m_p2(p2), m_p3(p3),
|
|
m_l1(Line(p1, p2)), m_l2(Line(p2, p3)), m_l3(Line(p3, p1)) {}
|
|
|
|
bool is_point_inside(Point other) const
|
|
{
|
|
return m_l1.is_point_right(other) && m_l2.is_point_right(other) && m_l3.is_point_right(other);
|
|
}
|
|
|
|
Line l1()
|
|
{
|
|
return m_l1;
|
|
}
|
|
|
|
Line l2()
|
|
{
|
|
return m_l2;
|
|
}
|
|
|
|
Line l3()
|
|
{
|
|
return m_l3;
|
|
}
|
|
};
|
|
#endif // TRIANGLE_H
|