https://github.com/kikito/bresenham.lua ... senham.lua
I understand what the bresenham algorithm is and how it works, but I just cannot wrap my head around why this code actually works.
How does this bresenham code even work?
-
- Citizen
- Posts: 52
- Joined: Wed Dec 23, 2015 4:03 pm
Re: How does this bresenham code even work?
This is, quite frankly, the Lua statement-to-statement adaptation of a standard implementation of the (integer based) Bresenham line algorithm.
The only difference from the line-plotting case is that you are calling a callback function to check for visibility occlusion and test whether the line from point (x0,y0) to point (x1,y1) do not cross any "wall".
By the way, I implemented a LOS algorithm in a very similar way.
What puzzles you the most?
The only difference from the line-plotting case is that you are calling a callback function to check for visibility occlusion and test whether the line from point (x0,y0) to point (x1,y1) do not cross any "wall".
By the way, I implemented a LOS algorithm in a very similar way.
What puzzles you the most?
Who is online
Users browsing this forum: No registered users and 1 guest