I've been working on implementing a Line of Sight calculation tool, but the results often appear incorrect. I am unable to use other libraries or tools to do the calculations, so please do not recommend any.
It is my understanding that the basic algorithm for calculating visibility between two points is:
- Gather many points along the line (preferably equidistant from one another)
- For each point on the line, calculate the viewing angle between it and the starting point.
- For each point(P) on the line, visit each point that came before it(P') and if any point P' has a viewing angle greater than the viewing angle of P, then that point P is not visible.
It seemed straight forward, but I am getting incorrect visualizations. Is there anything wrong with my assumption on how to calculate visibility between the various points on a line?
(In order to calculate the viewing angle between points, I am using the method outlined here.)