Crossing of obstacle and grid line

In the procedure for obstacles it is necessary to determine the crossing point of the obstacle and a grid line in the computational grid. The obstacle is composed of straight sides. Let one side have the end points $\vec{x}_3 = (x_3,y_3)$ and $\vec{x}_4 = (x_4,y_4)$. The end points of the grid line (both computational grid points) are $\vec{x}_1=(x_1,y_1)$ and $\vec{x}_2 = (x_2,y_2)$. The crossing point must obey the following equation


  $\displaystyle \vec{x}_1 + \lambda (\vec{x}_2-\vec{x}_1) = \vec{x}_3 + \mu(\vec{x}_4-\vec{x}_3)
$ (3.114)



where both $\lambda $ and $\mu$ must be between 0 and 1. It follows that


  $\displaystyle \lambda = \frac{(x_1-x_3)(y_2-y_1) - (y_1-y_3)(x_2-x_1)}
{(x_4-x_3)(y_2-y_1) - (y_4-y_3)(x_2-x_1)}
$ (3.115)



and


  $\displaystyle \mu = \frac{(x_1-x_3)(y_4-y_3) - (y_1-y_3)(x_4-x_3)}
{(x_4-x_3)(y_2-y_1) - (y_4-y_3)(x_2-x_1)}
$ (3.116)



If the denominator in both expressions is zero, the two lines are parallel and it is assumed that there is no crossing.



The SWAN team 2024-09-09