Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.