33 template <
class Po
intT>
43 : src_point(), tgt_point()
49 : src_point(sp), tgt_point(tp)
55 : src_point(sp), tgt_point(std::forward<PointT>(tp))
61 : src_point(std::forward<PointT>(sp)), tgt_point(tp)
67 : src_point(std::forward<PointT>(sp)), tgt_point(std::forward<PointT>(tp))
73 : src_point(s.src_point), tgt_point(s.tgt_point)
89 src_point = s.src_point;
90 tgt_point = s.tgt_point;
103 std::swap(src_point, s.src_point);
104 std::swap(tgt_point, s.tgt_point);
124 src_point = std::move(sp);
134 tgt_point = std::move(tp);
139 return src_point.distance_with(tgt_point);
144 return p.is_to_right_from(src_point, tgt_point);
149 return p.is_to_right_on_from(src_point, tgt_point);
154 return p.is_to_left_from(src_point, tgt_point);
159 return p.is_to_left_on_from(src_point, tgt_point);
164 return p.is_collinear_with(src_point, tgt_point);
169 return p.is_between(src_point, tgt_point);
200 if (tgt_point.get_x() == src_point.get_x())
202 if (src_point.get_y() < tgt_point.get_y())
208 return real_t(tgt_point.get_y() - src_point.get_y()) /
209 real_t(tgt_point.get_x() - src_point.get_x());
238 const typename PointT::NumberType & x1 = src_point.get_x();
239 const typename PointT::NumberType & y1 = src_point.get_y();
241 const typename PointT::NumberType & x2 = p.get_x();
242 const typename PointT::NumberType & y2 = p.get_y();
244 const typename PointT::NumberType x =
247 const typename PointT::NumberType y = m1 * (x - x1) + y1;
255 auto dxt = tgt_point.get_x() - src_point.get_x();
256 auto dyt = tgt_point.get_y() - src_point.get_y();
257 auto dxs = s.tgt_point.get_x() - s.src_point.get_x();
258 auto dys = s.tgt_point.get_y() - s.src_point.get_y();
260 auto dot = dxt * dxs + dyt * dys;
261 auto det = dxt * dys - dyt * dxs;
263 return atan2(det, dot);
274 throw std::domain_error(
"Segments are parallels");
276 const typename PointT::NumberType & x1 = src_point.get_x();
277 const typename PointT::NumberType & y1 = src_point.get_y();
279 const typename PointT::NumberType & x2 = s.src_point.get_x();
280 const typename PointT::NumberType & y2 = s.src_point.get_y();
285 const typename PointT::NumberType x =
288 const typename PointT::NumberType y = m1 * (x - x1) + y1;
295 return src_point == tgt_point;
305 return src_point == s.src_point and tgt_point == s.tgt_point;
310 return not (*
this == s);
328 # endif // DSGSEGMENT_H bool is_to_right_on_from(const PointT &p) const
Definition: segment.H:157
bool intersects_with(const GenSegment &s) const
Definition: segment.H:189
PointT intersection_with(const GenSegment &s) const
Definition: segment.H:271
bool is_perpendicular_with(const GenSegment &s) const
Definition: segment.H:217
const PointT & get_src_point() const
Definition: segment.H:107
GenSegment(const PointT &sp, const PointT &tp)
Definition: segment.H:48
void set_tgt_point(const PointT &tp)
Definition: segment.H:127
double real_t
Definition: types.H:51
double counterclockwise_angle_with(const GenSegment &s)
Definition: segment.H:253
Definition: segment.H:314
Definition: segment.H:320
bool is_to_left_from(const PointT &p) const
Definition: segment.H:142
bool operator==(const GenSegment &s) const
Definition: segment.H:303
bool is_null() const
Definition: segment.H:293
bool intersects_properly_with(const GenSegment &s) const
Definition: segment.H:177
bool is_collinear_with(const PointT &p) const
Definition: segment.H:162
bool real_equal(T, T)
Definition: math.H:91
constexpr real_t INF
Definition: math.H:38
Definition: point2D.H:241
GenSegment(PointT &&sp, const PointT &tp)
Definition: segment.H:60
void set_src_point(const PointT &sp)
Definition: segment.H:117
bool is_to_right_from(const PointT &p) const
Definition: segment.H:152
bool is_parallel_with(const GenSegment &s) const
Definition: segment.H:212
void set_tgt_point(PointT &&tp)
Definition: segment.H:132
GenSegment & operator=(const GenSegment &s)
Definition: segment.H:84
bool contains_to(const GenSegment &s) const
Definition: segment.H:172
const PointT & get_tgt_point() const
Definition: segment.H:112
real_t length() const
Definition: segment.H:137
bool contains_to(const PointT &p) const
Definition: segment.H:167
bool operator!() const
Definition: segment.H:298
GenSegment(const PointT &sp, PointT &&tp)
Definition: segment.H:54
GenSegment()
Definition: segment.H:42
real_t slope() const
Definition: segment.H:198
void swap(GenSegment &s)
Definition: segment.H:101
bool operator!=(const GenSegment &s) const
Definition: segment.H:308
GenSegment(PointT &&sp, PointT &&tp)
Definition: segment.H:66
GenSegment(const GenSegment &s)
Definition: segment.H:72
void set_src_point(PointT &&sp)
Definition: segment.H:122
bool is_to_left_on_from(const PointT &p) const
Definition: segment.H:147
GenSegment get_perpendicular(const PointT &p) const
Definition: segment.H:233
GenSegment(GenSegment &&s)
Definition: segment.H:78
GenSegment get_opposite() const
Definition: segment.H:266