Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Point: Fix a division by zero in getPointAlongLine
  • Loading branch information
tpoole committed Mar 17, 2022
1 parent db3a0a1 commit 0d82541
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/juce_graphics/geometry/juce_Line.h
Expand Up @@ -203,7 +203,8 @@ class Line
*/
Point<ValueType> getPointAlongLine (ValueType distanceFromStart) const noexcept
{
return start + (end - start) * (distanceFromStart / getLength());
const auto length = getLength();
return length == 0 ? start : start + (end - start) * (distanceFromStart / length);
}

/** Returns a point which is a certain distance along and to the side of this line.
Expand Down

0 comments on commit 0d82541

Please sign in to comment.