-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interesting Conclusion #30
Comments
The idea is to make the code not use divisions and float. Note that if you have an inequality: |
I remember having a hard time trying to grasp that part until eventually losing my trust to the writer and opening this issue angrily. Now I look again, I understand how the improvement is made and unfortunately, the explanation is really shallow and somewhat irrelevant to the change that is made. 'Taking the division out of the loop', after 'noticing that each division has the same divisor', would be just by calculating
But the change writer made (4th attempt) does this:
The improvement made here (not multiplying at every step) is possible not only because of the common divisor, also because of unmentioned proportional increase of dividend(x-x0) in the loop. Actually, it is more about the latter and one only needs to see that Whatever. My guess is, writer already had the resulting snippets (maybe from classes) and showed some impatience while filling the gaps. I also think the resulting explanation has something to do with trying to be smart (sorry, this costed me too much time and i am angry again). |
While I do agree with your general feeling, we should also be fair considering who this tutorial was supposedly meant for. The important point being that the algorithm was most likely meant to be derived by readers (you can find my derivation here: https://github.com/vchizhov/ssloy_software_renderer/blob/master/src/line_bresenham.hpp). The algorithm description in wikipedia is also quite helpful (a bit different from mine, but ultimately equivalent): https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#Algorithm_for_integer_arithmetic |
Here is a quote from lesson 1:
I can't understand how noting that each division has the same divisor helps us for making next improvements.
The text was updated successfully, but these errors were encountered: