# Determine height on Bresenham line algorithm path

I have path from Bresenham line algorithm, example for A->B vector:

Path is [(0,5), (0,4), (1,4), (1,3), (1,2), (1,1), (2,1), (2,0)]. Considering A height is 10 meters, B height is 5 meters and a tree at position 1,1 is 5,5 meters:

How to know if point B is visible from point A ? My real question is: How to know the A->B vector height when it is "above" specific position, so here 1,1 ?

• With regard to your use of Bresenham here, can you define in a bit more detail what criteria we should use to determine visibility? Say the Bresenham algorithm draws two vertically stacked pixels on this particular column. Have we blocked visibility if we cover just one of the two pixels? Or do we need to cover both to block the line? (ie. does the green dot at (1, 1) in the diagram above block the ray? Or do we need an occluder at (1, 2) or (2, 1)? – DMGregory Nov 28 '17 at 17:16
• I closed the question on math exchange. Thanks for rules remind. @DMGregory Yes visibility blocked if just one of them is "to high". For simplify the question can be: Does exist a coordonate (taking it's height) on vector (in real, on Bresenham line) who block the vector. – bux Nov 29 '17 at 13:57

$$y = \vec A_y + (\vec B_y - \vec A_y)\space \cdot\space\frac{ x}{\vec B_x - \vec A_x}$$