English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

We have 3 points that make a triangle.
I need an algorithm to determine, for any other points if they are in the shape or nor?

2006-07-10 11:35:56 · 6 answers · asked by rahbar_kambiz 1 in Computers & Internet Programming & Design

6 answers

I'm going to assume you want to know whether or not a point is in the interior of the triangle.

First, write the three equations of the three lines. You can use point-point form, but I think it would be worth it to put them in slope-intercept form.

For each equation, compare it to the point that's not on the line to see which side of the line the triangle lies on. For example, if the line is y = 5x + 4 and the third point is (2, 3), you could plug in those two values to get 3 = 5(2) + 4... now actually, 3 is *less* than 5(2) + 4, so that means the point satisfies the inequality y is less than 5x + 4.

Do this for all three equations and change them into the appropriate inequalities.

Now to see if a point lies in the interior of the triangle, you just need to see if it satisfies the system of inequalities.

You can include the border or not as you prefer by making them strict or not strict inequalities.

2006-07-10 11:52:32 · answer #1 · answered by mathsmart 4 · 0 0

You need to provide a bit more detail: when you say 'for any other points', do you mean you have 3 random points and you want to figure out if they make a triangle? Or do you mean you have a random number of points (for example, 7) and want to determine if they want to make a triangle?

If you have a collection of just 3 points, you can check if the angle made between points 1-2, points 1-3, and points 2-3 sum up to 180 degrees.

Since you have 3 points I assume you have a coordinate system. You can use a simple x-y plane to plot the points, connect the lines between them, then check if the above angles all sum up to 180 degrees.

2006-07-10 18:41:49 · answer #2 · answered by Pras K 1 · 0 0

Al Gore Rhythm! I remember when he said that Hammer was his favorite rapper.

Anyhow, draw an X/Y coordinate system, with 0,0 being in the middle. Put your three defined points on the graph and record their coordinates. Draw a line between the three points. Now you can write down what coordinates will go inside the triangle, and what ones will not. I really don't know much about algorithm's, but this seems like a sensible way.

2006-07-10 18:39:53 · answer #3 · answered by Fun and Games 4 · 0 0

any three point would make a triangle unless they r in a line. So find the line between each point and see if that line intersects a point. You do know math right?

2006-07-10 18:52:13 · answer #4 · answered by iammisc 5 · 0 0

BEGIN
Read the value of n.
Divide n by 2 and store the remainder in rem.
If rem is 0, go to step 7.
Print "n is an odd number".
Go to step 8.
Print "n is an even number".
END

2006-07-10 18:40:10 · answer #5 · answered by Anonymous · 0 0

are you trying to get me to do your homework? the answer is easy, just think about it dimensionally. for a small fee i will tell you.

2006-07-10 18:39:31 · answer #6 · answered by patch 2 · 0 0

fedest.com, questions and answers