File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ struct LargestTriangleThreeBuckets
29
29
}
30
30
31
31
// Bucket size. Leave room for start and end data points
32
- TData every = static_cast <TData>(sourceSize - 2 ) / static_cast <TData>(destinationSize - 2 );
32
+ // Note: We cast to double to avoid floored window propagation
33
+ double every = static_cast <double >(sourceSize - 2 ) / static_cast <double >(destinationSize - 2 );
33
34
34
35
size_t aIndex = 0 ; // Initially a is the first point in the triangle
35
36
@@ -74,7 +75,9 @@ struct LargestTriangleThreeBuckets
74
75
TData area = std::abs (
75
76
((pointAX - avgX) * (source[rangeOffs].*y - pointAY)) -
76
77
((pointAX - source[rangeOffs].*x) * (avgY - pointAY))
77
- ) / 2 ;
78
+ );
79
+ // Note: Normally you need to also divide area by 2, but all we care about
80
+ // is the largest area, so we can skip the division by a constant factor of 2
78
81
if (area > maxArea)
79
82
{
80
83
maxArea = area;
You can’t perform that action at this time.
0 commit comments