ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
120 stars 77 forks source link

Fixed a bug with the implementation of Bresenham's line algorithm #1044

Closed ayshih closed 1 year ago

ayshih commented 1 year ago

The implementation of Bresenham's line algorithm used for get_pixels_on_line() has a bug because it uses > instead of >= and < instead of <=. Compare against the final code example in this section on the Wikipedia article: https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#All_cases. ~This bug means that the pixels other than the closest ones are occasionally chosen.~

Edit: After further investigation, it appears that the difference in comparison operator simply means a different choice is made when two pixels are equally close to the line. After I confirm, I'll close this PR as an unnecessary change.

ayshih commented 1 year ago

Sorry for the noise! It turns out this "bug" is simply a difference in choice when there are two pixels equally close to the line. This change is not necessary.

ejeschke commented 1 year ago

@ayshih , thanks for the interest and the thoughtful analysis!