Merge pull request #10915 from xtemp09/path-fix2

[Path] Prevent division by zero
This commit is contained in:
sliptonic
2023-10-12 07:11:25 -05:00
committed by GitHub

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());