Skip to content

Commit

Permalink
fix intersection interval for degenerate line segments
Browse files Browse the repository at this point in the history
  • Loading branch information
derohde committed Mar 21, 2021
1 parent b2f300c commit 6edc279
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ class Point : public Coordinates {
inline Interval intersection_interval(const distance_t distance_sqr, const Point &line_start, const Point &line_end) const {
const Vector u = line_end-line_start, v = *this - line_start;
const distance_t ulen_sqr = u.length_sqr(), vlen_sqr = v.length_sqr();

if (ulen_sqr == 0) {
if (vlen_sqr <= distance_sqr) return Interval(0, 1);
else return Interval();
}

const distance_t p = -2. / ulen_sqr * (u * v), q = (vlen_sqr - distance_sqr) / ulen_sqr;

Expand Down

0 comments on commit 6edc279

Please sign in to comment.