[Path] Prevent division by zero

Closes #8102.
This commit is contained in:
xtemp09
2023-10-03 13:07:52 +07:00
parent 6080bf2451
commit eff8b9a419

View File

@@ -67,7 +67,8 @@ namespace {
// calculate the orthogonal projection of p onto s
// ((p dot s) / (s dot s)) * s (https://en.wikibooks.org/wiki/Linear_Algebra/Orthogonal_Projection_Onto_a_Line)
// and it back by original offset to get the projected point
double proj = (p.x() * s.x() + p.y() * s.y()) / (s.x() * s.x() + s.y() * s.y());
const double proj = (p.x() * s.x() + p.y() * s.y())
/ (s.x() * s.x() + s.y() * s.y() + std::numeric_limits<double>::epsilon());
Voronoi::point_type pt;
{
pt.x(offset.x() + proj * s.x());