Tell if the point A(x,y) lies inside the triangle formed by the points P(a,b) , Q(c,d) , R(e,f) .
I can solve this by finding the sum of the areas of the triangles - APQ , AQR , ARP and comparing this with the area of the triangle PQR. But it takes a good amount of time (which is not good for M.C.Q based exams). Is there any cleaver way to solve this?
Set up some coordinate system such that, in this coordinate system, the points are given by $(x_1, y_1)$, $(x_2, y_2)$, and $(x_3, y_3)$. Let the given point be "(x*, y*)". Now determine whether the given point is on the same side of each line as the third vertex:
1) Find a, b such that both $(x_1, y_1)$ and $(x_2, y_2)$ lie on line y= ax+ b (in other words, find the equation of the line determined by those two points). Determine if $y_3- ax_3- b$ and $y^*- ax^*- b$ have the same sign. If not we are done and the answer is "no, the point (x*, y*) does not lie inside this triangle. If "yes" then
2) Find a, b such that both $(x_1, y_1)$ and $(x_3, y_3)$ lie on line y= ax+ b. Determine if $y_2- ax_2- b$ and $y^*- ax^*- b$ have the same sign. If not we are done and the answer is "no", the point (x*, y*) does not lie inside this triangle. If "yes" then
3) Find a, b such that both $(x_2, y_2)$ and $(x_3, y_3)$ lie on line y= ax+ b. Determine if $y_1- ax_1- b$ and $y^*- a^x*- b$ have the same sign. If not we are done and the answer is "no", the point (x*, y*) does not lie inside this triangle. If "yes" then point (x*, y*) does lie inside the triangle.
Note: if, for i= 1, 2, or 3, $y_i- ax_i- b$ is 0 then the three points do not define a triangle. If, for any i= 1, 2, or 3, $y^*- ax^*- b$ is 0, the points lies on the triangle, not inside it.