# Triangle Geometry

Hi there,so i'm trying to write a vb.net program which will tell me whether a cartesian point in 2D lies inside or outside of a triangle.
I'm not looking for the code or anything, i'm merely wondering how one does this type of calculation manually?
could the cross product be used?if the results of all three cross products point in the same direction the point lies inside the triangle, otherwise it lies outside the triangle???i read this in a forum but i don't honestly understand the logic behind it?
or is there a much simpler way i have overlooked?
any advice would be much appreciated
debs I think the idea behind your approach is to consider a triangular prism.
http://www.math.washington.edu/~nichifor/Math402/prism_drawing.bmp

Given the points A,B,C of your triangle you have to set up three planes in order to get a triangular prism. Actually, you only need the normal vectors and define them to point "inwards".

Once you have those normal vectors n1, n2 and n3 you can determine
whether your point P, which you want to examine, lies within the prism and whether it lies within your triangle (x-y-plane with z=0).

HallsofIvy
Homework Helper
How are you given each side of the triangle? If you are given the vertices of the triangle you can write the line between two points in the form ax+ by+ c= 0. If a point is on one side of that line, ax+ by+ c will be larger than 0, if on the other, less than 0.

For each line, check to see if the given point is on the same side as the third vertex. (check to see if ax+ by+ c has the same sign for both.)

If the given point is on the same side of the line given by each pair of vertices as the third vertex, the the point is inside the triangle.

thanks for the help.just with the 2nd method,you're saying all i need do is use y-y1 = m(x-x1) and use to of the vertices to calculate the slope in each case?

HallsofIvy