# Line triangle intersection

Could you please explain how the math behind the first answer to this stack overflow questions works:

http://stackoverflow.com/questions/3590308/testing-if-a-line-has-a-point-within-a-triangle

Thanks.

-

Let's take the image from the anwer:

You can think of the red line as a two dimensional plane, where $4x − 3y + 2 = 0$ is it's coordinate equation with some normal vector

$$\vec{n} = \begin{pmatrix} 4 \\ -3 \end{pmatrix}$$

that is orthogonal to the line.

Now, by substituting a point into the equation, you get the distance of point and line along $\vec{n}$ (see. Hesse's normal form). While we don't actually care for the distance itself, we do care for it's sign. Positive sign indicates the point's lying on the side $\vec{n}$ points to, a negative one indicates the opposite side.

Now, if all the values have the same sign, all triangle points lie on the same side of the line, i.e. there are no intersections. With different signs, the triangle must hit the line.

-