CS19002 Programming and Data Structures Laboratory | Spring 2009, Section 2 |
Write a C program that, upon the input of a triangle T and a point P, determines whether P lies inside, or outside, or on T. This problem can be solved as follows. Suppose that U = (u1,u2) and V = (v1,v2) are two points. A point P = (x,y) lies to the left, or to the right, or on the oriented line UV according as whether the determinant
1 u1 u2 1 v1 v2 1 x y
is positive, or negative, or zero. The point P lies inside the triangle T with vertices A,B,C if and only if P lies on the same side of the three oriented sides AB, BC and CA of T.
For simplicity, assume that P does not belong to two sides of T, that is, P is not a vertex of T. Assume also that if P lies outside T, then P is not collinear with a side of T.
Report the output of your program on the following inputs.