While testing your algorithm and implementation on a middle large area, I noticed a problem in line
if (rightBound <= right) break; // right < rightBound
(line numer 422) in file LineOfSightScanner.cpp
In the underlying comparison
return o.d*n > o.n*d;
of the Fraction objects, the data range of int is easily exceeded, which can lead to negative numbers where there should be positive ones, which can lead to a comparison result of false instead of true, which can lead to an infinite loop.
I changed n and d of the Fraction class to long long for a simple solution to the problem (ignoring some implicit casts with potential data loss); for sure not the best way.
Maybe you can update your implementation for these cases.
Great work, easy to use, extensive description!
While testing your algorithm and implementation on a middle large area, I noticed a problem in line
if (rightBound <= right) break; // right < rightBound(line numer 422) in file LineOfSightScanner.cpp
In the underlying comparison
return o.d*n > o.n*d;of the Fraction objects, the data range of int is easily exceeded, which can lead to negative numbers where there should be positive ones, which can lead to a comparison result of false instead of true, which can lead to an infinite loop.
I changed n and d of the Fraction class to long long for a simple solution to the problem (ignoring some implicit casts with potential data loss); for sure not the best way.
Maybe you can update your implementation for these cases.
Great work, easy to use, extensive description!