How do we know if the coordintes of a point lie within and outside a triangle?

In summary: ABC, then the point P is within the triangle. However, if the sum of the areas is greater or less than the area of the triangle, then the point lies outside the triangle.In summary, to determine if a point (x, y) lies within or outside a triangle with vertices A, B, and C, we can find the equation of the line connecting two of the vertices and use it to determine the value of that function at x. If it is greater or less than the value of y at that point, then the point is outside the triangle. Another method is to find the sum of the areas of the triangles formed between the point and each pair of vertices. If the sum is
  • #1
david07
6
0
ex: if the origin points are A = (0, 0)

B = (3,5)
C= (6,3)

How do we know that point (3,1) lies within or outside the triangle using mathematical formulas?

I know there is a similar topic to this somewhere in forums but i don't understand where a & b comes from.

please can anyone help me out?

thanks
 
Mathematics news on Phys.org
  • #2
Well, if you're looking at that certain point, the I guess you can find the equation of the line connecting A and C, and simply find the value of that function at x = 3. If it's greater than 1, then (3, 1) doesn't lie in the triangle.
 
  • #3
Thanks but no not for that particular point.

I mean the coordinates can be different except the origin. (0, 0)

how do we know if we have to find the equation of line of AC or AB or BC??
 
  • #4
If you take that particular problem and draw the triangle, you can determine which sides are where. The picture is important. Of the three points, (where X is the first coordinate, Y the second), (3,5) is the highest point, while (6,3) lies the furthest along the X-axis.

Moving along the X-axis from (0,0) to (6,3) we have a slope of 1/2. The point in question (3,1), connected to (0,0), has a slope of Y/X = 1/3. So that line and point is outside the triangle.
 
Last edited:
  • #5
Well, I can think of two ways. First, with areas. Say the vertices are A, B and C. We denote the area of that triangle K. A point P, if inside the triangle, satisfies the condition

PAB + PAC + PCB = K.

That is, the sum of the area of all possible triangles formed between two vertices of ABC and P is K. A point that does not satisfy this equality is located outside the triangle.

The second way is equivalent but goes along with the angles. That is (I use < to denote angles):

<APB + <APC + <BPC = 360

PS: Note that points along the sides of the triangle ABC are included.
 
Last edited:
  • #6
You know the vertices so you can easily get the linear equations [call them y1=, y2= and y3=] for the three lines that contain each side of the triangle.

[Method caveat: begin with a point known to be OUTSIDE the triangle. Find the line equation y4= from that outside point to the point you want to check. Determine if y4 intersects each of y1, y2 or y3. Simple to program this algorithm. Count the number of intersections.

If you begin OUTSIDE the triangle, and you have no intersections, then you are outside the triangle (duh). One intersection, you are inside the triangle. Two intersections, you are outside the triangle.

This trick works for any polygon. If you begin outside the polygon, count the number of intersections and if you have an even number of intersections, you are outside the polygon. If you have an odd number of intersections, you are inside the polygon.
 
  • #7
forrest747 said:
You know the vertices so you can easily get the linear equations [call them y1=, y2= and y3=] for the three lines that contain each side of the triangle.

[Method caveat: begin with a point known to be OUTSIDE the triangle. Find the line equation y4= from that outside point to the point you want to check. Determine if y4 intersects each of y1, y2 or y3. Simple to program this algorithm. Count the number of intersections.

If you begin OUTSIDE the triangle, and you have no intersections, then you are outside the triangle (duh). One intersection, you are inside the triangle. Two intersections, you are outside the triangle.

This trick works for any polygon. If you begin outside the polygon, count the number of intersections and if you have an even number of intersections, you are outside the polygon. If you have an odd number of intersections, you are inside the polygon.

Certainly a valid method, but it's a shame there is no equivalent analytical method...
 
  • #8
Werg22 said:
Well, I can think of two ways. First, with areas. Say the vertices are A, B and C. We denote the area of that triangle K. A point P, if inside the triangle, satisfies the condition

PAB + PAC + PCB = K.

That is, the sum of the area of all possible triangles formed between two vertices of ABC and P is K. A point that does not satisfy this equality is located outside the triangle.

The second way is equivalent but goes along with the angles. That is (I use < to denote angles):

<APB + <APC + <BPC = 360

PS: Note that points along the sides of the triangle ABC are included.

so u mean first find the area of the triangle using the coordinate points.

and then do PAB+PAC+PCB=are of triangle using the given coordinate points.

what i don't understand is how does PAB+PAC+PCB work??

I mean AB, AC, CB can be found using distance formula but P is suppose some point (0,2) how does that work?
 
  • #9
wow that is a really cool question. i don't know the NSWER yet.

heres a suggestion, say the vertices are A,B,C, and the extra point is D.

then for each pair of vertices say A,B, try to decide if C and D are on h same side of line joining A,B.

the linear equation which equals zero at both A,B, will hve the same sign at points on the same side of line AB.

does this help?
 
  • #10
david07 said:
so u mean first find the area of the triangle using the coordinate points.

and then do PAB+PAC+PCB=are of triangle using the given coordinate points.

what i don't understand is how does PAB+PAC+PCB work??

I mean AB, AC, CB can be found using distance formula but P is suppose some point (0,2) how does that work?

I'm afraid I don't quite get the question... maybe I should have been clearer with the expression PAB + PAC + PCB. PAB, PAC, PCB represent the areas of the triangles PAB, PAC and PCB, respectively. So if the sum of the areas of the triangles PAB, PAC and PCB, is equal to the area of ABC, then point P lies inside the triangle. I know it's tedious to calculate all these areas (personally I find Heron's formula very bad looking) but it's still a solution...

Edit: Oh I see what you mean. ABC and P represent the points, not the sides!
 
Last edited:
  • #11
mathwonk said:
wow that is a really cool question. i don't know the NSWER yet.

heres a suggestion, say the vertices are A,B,C, and the extra point is D.

then for each pair of vertices say A,B, try to decide if C and D are on h same side of line joining A,B.

the linear equation which equals zero at both A,B, will hve the same sign at points on the same side of line AB.


does this help?

Though I didn't quite get this part, if it's possible to easily verify if C and D are on the same side, there's yet another solution: if C and D are on the same side, and the x coordinate of C is smaller than that of D or bigger, depending on weather they are on the right or left of segment AB, and if the linear equation that goes through C and D crosses the segment AB, then D is inside the triangle. I know I'm just stating the obvious, but someone must do it.
 
  • #12
This appears to work: use two of the edges as a basis for the plane. The coordinates of the unknown point in this "edge space" must be non-negative and must sum to one or less.

Algorithm: Place one of the vertices at the origin. Denote the other two vertices as
[tex]\bmatrix x_i \\ y_i\endbmatrix [/tex]
Denote the point in question as
[tex]\bmatrix x \\ y\endbmatrix[/tex]

The coordinates of this point are

[tex]\bmatrix u\\v \endbmatrix =
\bmatrix x_1 & x_2 \\y_1 & y_2 \endbmatrix^{-1}
\bmatrix x \\ y\endbmatrix[/tex]

The point is inside the triangle if [itex]u,v>=0[/itex] and [itex]u+v<=1[/itex].
 
Last edited:
  • #13
the interior of a triangle is the intersection of the three hal planes determiend by the three sides.

so if a point is on the same side of each side as the third vertex, it is in the interior.

e.g. take the triangle with vertices (0,0), (0,1),(1,0).

the three sides determine the three lines x=0, y=0, and x+y-1=0.

now applying the first equation, namely x, to the third vertex (1,0) gives 1, so an interior point shoiuld have x>0.

the second side with vertices (0,0), (1,0), determines the line y=0 and the third vertex has y=1 so the interior points have y>0. then x+y-2 = 0 for the third side, and the third vertex has x+y-1 = -1, so the interior points satisfy x+y-1 < 0.

hence an interior point is one with x>0, y>0 and x+y < 1. e.g. (1/3,1/2).
 
Last edited:
  • #14
ok i kinda understand werg22 area method but i still don't get the right answer.
Could someone please help me out with this

A (0,0)
B (1,5)
C (4,1)
P (2,2)

I am getting the area of ABC as 9.5

PAB+PAC+PCB=0

Technically (2,2) should be in but according to your method if it isn't equal to area of ABC then it is outside.

Don't understand what mistake i am making.

Can someone help please.

Thanks

technically
 
  • #15
PAB+PAC+PCB=0

What is the meaning of this?
 
  • #16
mathwonk said:
Take the triangle with vertices (0,0), (0,1),(1,0).

the three sides determine the three lines x=0, y=0, and x+y-1=0.

This is a nice canonical triangle. Let (u,v) be the Cartesian coordinates of a point on a plane with a triangle with vertices at (0,0),(1,0),(0,1). As mathwonk pointed out, the conditions that a point (u,v) be in the interior of the canonical triangle are u,v>0 and u+v<1.

This canonical triangle can be mapped to a triangle with vertices at (0,0),(x1,y1),(x2,y2) by the transformation

[tex]\bmatrix x\\y\endbmatrix =
\bmatrix x_1 & x_2 \\y_1 & y_2 \endbmatrix\;\bmatrix u\\v\endbmatrix[/tex]

The inverse of this transformation maps from the generic triangle to the canonical triangle:

[tex]\bmatrix u\\v \endbmatrix =
\bmatrix x_1 & x_2 \\y_1 & y_2 \endbmatrix^{-1}
\bmatrix x \\ y\endbmatrix[/tex]

which is what I stated in post #12 (except I did not have strict inequalities).
 
  • #17
I mean when i find PAB, PAC, PCB i get all of those areas as 0.

which is not equal to the area of ABC.

hence (2,2) does not fall in the triangle ABC although it is supposed to be.
 
  • #18
david07 said:
I mean when i find PAB, PAC, PCB i get all of those areas as 0.

which is not equal to the area of ABC.

hence (2,2) does not fall in the triangle ABC although it is supposed to be.

How did you come up with all those area equal to 0? It's not true. =.="

An area of a triangle is 0 only when 3 points overlaps each other, or they are co-linear. Your example is neither of the two cases above, so your triangle does have area.
 
  • #19
D H said:
This is a nice canonical triangle. Let (u,v) be the Cartesian coordinates of a point on a plane with a triangle with vertices at (0,0),(1,0),(0,1). As mathwonk pointed out, the conditions that a point (u,v) be in the interior of the canonical triangle are u,v>0 and u+v<1.

This canonical triangle can be mapped to a triangle with vertices at (0,0),(x1,y1),(x2,y2) by the transformation

[tex]\bmatrix x\\y\endbmatrix =
\bmatrix x_1 & x_2 \\y_1 & y_2 \endbmatrix\;\bmatrix u\\v\endbmatrix[/tex]

The inverse of this transformation maps from the generic triangle to the canonical triangle:

[tex]\bmatrix u\\v \endbmatrix =
\bmatrix x_1 & x_2 \\y_1 & y_2 \endbmatrix^{-1}
\bmatrix x \\ y\endbmatrix[/tex]

which is what I stated in post #12 (except I did not have strict inequalities).


I got the point of mapping the triangle to a canonical triangle...

But I am hazy about the process, with the all the formulae put in codes. Can you please simplify it a li'l.
 
  • #21
Hi,

We can find a function fun for a triangle such that:
* fun(x,y) = 0 if (x,y) lies on the triangle, i.e., fun(x,y) = 0 is an equation for the triangle;
* fun(x,y) < 0 if (x,y) lies inside the triangle;
* fun(x,y) > 0 if (x,y) lies outside the triangle.

The function for the triangle ABC is
fun(x,y) = 3x - 6y - 21 + abs(7x - 21) + abs(9x - 18y + 21 - abs(7x - 21)).

Since fun(3,1) = 12 > 0, (3,1) lies outside the triangle ABC.
 

1. What are the coordinates of a point?

The coordinates of a point represent its location on a two-dimensional plane. They are usually written in the form (x,y), where x represents the horizontal distance from a fixed point and y represents the vertical distance from that same point.

2. How do we determine if a point lies within a triangle?

To determine if a point lies within a triangle, we can use the Triangle Area Formula. This formula takes the coordinates of the three vertices of the triangle and the coordinates of the point in question, and calculates the area of the triangle. If the area is equal to the sum of the areas of the three smaller triangles formed by connecting the point to each vertex, then the point lies within the triangle.

3. How do we determine if a point lies outside a triangle?

If a point does not lie within a triangle, then it must lie outside. To determine this, we can use the same Triangle Area Formula mentioned above. If the area of the triangle is not equal to the sum of the areas of the smaller triangles, then the point lies outside the triangle.

4. Can a point lie on the edge of a triangle?

Yes, a point can lie on the edge of a triangle. This means that the point shares coordinates with one of the vertices of the triangle. To determine this, we can use the same Triangle Area Formula and if the area is equal to one of the smaller triangles, then the point lies on the edge of the triangle.

5. What are some real-life applications of determining whether a point lies within or outside a triangle?

Determining if a point lies within a triangle is a fundamental concept in geometry and has many real-life applications. For example, it can be used in navigation systems to determine if a location is within a specific area, in computer graphics to determine if a point is inside a shape for rendering purposes, and in engineering to determine if a point lies within the bounds of a structure or design.

Similar threads

Replies
5
Views
2K
Replies
1
Views
1K
  • Precalculus Mathematics Homework Help
Replies
3
Views
803
Replies
9
Views
946
Replies
3
Views
1K
  • Precalculus Mathematics Homework Help
2
Replies
40
Views
2K
Replies
8
Views
2K
Back
Top