25 # ifndef DSGTRIANGLE_H 26 # define DSGTRIANGLE_H 33 template <
class Po
intT>
44 GenTriangle(
const PointT & _p1,
const PointT & _p2,
const PointT & _p3)
45 : p1(_p1), p2(_p2), p3(_p3)
47 if (p1.is_collinear_with(p2, p3))
48 throw std::logic_error(
"Points are collinear");
52 : p1(t.p1), p2(t.p2), p3(t.p3)
104 if (_p1.is_collinear_with(p2, p3))
105 throw std::domain_error(
"The new point is collinear with the others");
112 if (_p1.is_collinear_with(p2, p3))
113 throw std::domain_error(
"The new point is collinear with the others");
120 if (p1.is_collinear_with(_p2, p3))
121 throw std::domain_error(
"The new point is collinear with the others");
128 if (p1.is_collinear_with(_p2, p3))
129 throw std::domain_error(
"The new point is collinear with the others");
136 if (p1.is_collinear_with(p2, _p3))
137 throw std::domain_error(
"The new point is collinear with the others");
144 if (p1.is_collinear_with(p2, _p3))
145 throw std::domain_error(
"The new point is collinear with the others");
157 return p3.is_to_right_from(p1, p2);
162 return p3.is_to_left_from(p1, p2);
167 if (p.is_between(p1, p2) or p.is_between(p2, p3) or p.is_between(p3, p1))
170 bool test = p.is_to_left_from(p1, p2);
172 if (p.is_to_left_from(p2, p3) != test)
175 if (p.is_to_left_from(p3, p1) != test)
210 if (p[i].is_between(p1, p2))
213 catch(
const std::domain_error &)
222 if (p[i].is_between(p2, p3))
225 catch(
const std::domain_error &)
237 if (p[i].is_between(p3, p1))
240 catch(
const std::domain_error &)
246 throw std::domain_error(
"Triangle does not intersects with segment");
253 return p1 == t.p1 and p2 == t.p2 and p3 == t.p3;
258 return not (*
this == t);
276 # endif // DSGTRIANGLE_H bool intersects_with(const GenSegment &s) const
Definition: segment.H:189
PointT intersection_with(const GenSegment &s) const
Definition: segment.H:271
bool intersects_properly_with(const SegmentType &s) const
Definition: triangle.H:186
const PointT & get_src_point() const
Definition: segment.H:107
bool is_clockwise() const
Definition: triangle.H:155
double real_t
Definition: types.H:51
bool operator==(const GenTriangle &t) const
Definition: triangle.H:251
bool operator!=(const GenTriangle &t) const
Definition: triangle.H:256
void set_p2(const PointT &_p2)
Definition: triangle.H:118
bool is_counterclockwise() const
Definition: triangle.H:160
void swap(GenTriangle &t)
Definition: triangle.H:80
const PointT & get_p3() const
Definition: triangle.H:97
bool intersects_properly_with(const GenSegment &s) const
Definition: segment.H:177
Definition: triangle.H:262
SegmentType intersection_with(const SegmentType &s)
Definition: triangle.H:200
GenTriangle & operator=(const GenTriangle &t)
Definition: triangle.H:62
real_t area() const
Definition: triangle.H:150
void set_p3(PointT &&_p3)
Definition: triangle.H:142
const PointT & get_p1() const
Definition: triangle.H:87
GenTriangle(const PointT &_p1, const PointT &_p2, const PointT &_p3)
Definition: triangle.H:44
Definition: point2D.H:241
void set_p2(PointT &&_p2)
Definition: triangle.H:126
void set_p1(const PointT &_p1)
Definition: triangle.H:102
const PointT & get_tgt_point() const
Definition: segment.H:112
const PointT & get_p2() const
Definition: triangle.H:92
GenTriangle(GenTriangle &&t)
Definition: triangle.H:57
GenSegment< PointT > SegmentType
Definition: triangle.H:42
GenTriangle(const GenTriangle &t)
Definition: triangle.H:51
bool intersects_with(const SegmentType &s) const
Definition: triangle.H:193
void set_p1(PointT &&_p1)
Definition: triangle.H:110
Definition: triangle.H:34
T abs(T)
Definition: math.H:83
void set_p3(const PointT &_p3)
Definition: triangle.H:134
real_t area_of_parallelogram(const GenPoint2D< NumberType > &, const GenPoint2D< NumberType > &, const GenPoint2D< NumberType > &)
Definition: math.H:129
bool contains_to(const PointT &p) const
Definition: triangle.H:165
bool contains_to(const SegmentType &s) const
Definition: triangle.H:181
Definition: triangle.H:268