# Does a point lie on the triangle?

It is given that there are four points where three points are used to form a traingle.How can I know the forth point whether it lies on the triangle(not inside or outside the triangle)?Can someone help me with this little problem?Thank you!
###### Who is Participating?

Billing EngineerCommented:
well, this is actually a basically math (geometry) problem.
once, you know the solution on math level, just translate it to the programming language you use.
btw: which programming language DO you use?

so, 1 point, either yes or no if it is on one of the 3 lines?
divide an conquer: you have to check, for the 3 lines between the 3 possible pairs of 2 points each time, if the point is on that line.

say, the 2 points are A and B, and the point to check is C
to know if a point is on a segment, 2 checks:
check 1: what is the Angle between AB and AC? if  0 -> then C is on the half-segment [AB)
check 2: what is the distance AB compared to the distance A? if 0 <= AC <= AB -> then C is closer to A than B

if both checks are true, then C is on the segment AB, hence on the line between A and B

0

Commented:
0

Author Commented:
actually I can find whether the point lies inside or outside the triangle,but I cannot test the forth point if it lies on the boundary of the triangle.(I am using C program)Also,I am not given the angle.
0

Commented:
the point is on the triangle if it is on one of the line segments.
using the point in polygon test mentioned above, instead of a sign change, you would get 0
0

Commented:
0

Commented:
0

Commented:
To test if a point lies exactly on a line
http://mathworld.wolfram.com/Collinear.html
To lie on a line segment it would also have to be between the end points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.