Browse Source

Fix to Line::getDistanceFromPoint to make it work for integer types

tags/2021-05-28
jules 8 years ago
parent
commit
61044c8bda
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      modules/juce_graphics/geometry/juce_Line.h

+ 3
- 3
modules/juce_graphics/geometry/juce_Line.h View File

@@ -251,7 +251,7 @@ public:
*/
Point<ValueType> getPointAlongLineProportionally (typename Point<ValueType>::FloatType proportionOfLength) const noexcept
{
return start + Point<ValueType> ((end - start) * proportionOfLength);
return start + (end - start) * proportionOfLength;
}
/** Returns the smallest distance between this line segment and a given point.
@@ -274,11 +274,11 @@ public:
if (length > 0)
{
auto prop = ((targetPoint.x - start.x) * delta.x
+ (targetPoint.y - start.y) * delta.y) / length;
+ (targetPoint.y - start.y) * delta.y) / (double) length;
if (prop >= 0 && prop <= 1.0)
{
pointOnLine = start + delta * static_cast<ValueType> (prop);
pointOnLine = start + delta * prop;
return targetPoint.getDistanceFrom (pointOnLine);
}
}


Loading…
Cancel
Save