1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Point: Fix a division by zero in getPointAlongLine

This commit is contained in:
Tom Poole 2022-03-17 11:34:32 +00:00
parent db3a0a1ae8
commit 0d82541728

View file

@ -203,7 +203,8 @@ public:
*/
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.