1. ## [geometry] Triangles

I have to classify some triangles. The only data are the coordinates of 3 points

I'm in trouble for angles. I'm calculating the slope (with $m=\frac{y_2-y_1}{x_2-x_1}$ and if $x_2 - x_1 = 0$ i consider $m = \frac{\pi}{2}$)of each side and then using
$angle = atan(m_1) - atan(m_2)$ for each angle

is it wrong? how can I be always sure to get the correct angle?

2. Originally Posted by 3n1gm4
I have to classify some triangles. The only data are the coordinates of 3 points

I'm in trouble for angles. I'm calculating the slope (with $m=\frac{y_2-y_1}{x_2-x_1}$ and if $x_2 - x_1 = 0$ i consider $m = \frac{\pi}{2}$)of each side and then using
$angle = atan(m_1) - atan(m_2)$ for each angle

is it wrong? how can I be always sure to get the correct angle?
When (x2 -x1) = 0,
m is not pi/2
rather, it means that the side is vertical.

Other than that, you are all correct.

----------------------
How can you always be sure to get the correct angle?

Using your method, solve for all 3 angles. Then check if their sum is pi.
If it is pi, then you got them all correct.
If their sum is not pi, then one, or two, or all 3 angles is/are not correct.

--------------------------
A long way to find the angles when the coordinates of the 3 vertices are given is
a) first solve for the lengths of the 3 sides
b) then find the angles by using the Law of Cosines.
c) then check if all 3 angles add up to pi again.

3. Originally Posted by ticbol
When (x2 -x1) = 0,
m is not pi/2
rather, it means that the side is vertical.

Other than that, you are all correct.
Yes the sides are vertical, and pi/2 is the wrong value? I can't do it in that way if sides are vertical right?

I need time to spend on Law of Cosines

4. Originally Posted by 3n1gm4
Yes the sides are vertical, and pi/2 is the wrong value? I can't do it in that way if sides are vertical right?

I need time to spend on Law of Cosines
If you are playing on triangles, only one side of a triangle can be vertical. The other two sides cannot be vertical anymore.

Since you are looking for an interior angle, you cannot say yet that that angle is pi/2 even if one of its ray is vertical. You still need to find the slope of the other ray that make up the angle.

ray here is side of triangle.

5. Originally Posted by ticbol
If you are playing on triangles, only one side of a triangle can be vertical. The other two sides cannot be vertical anymore.

Since you are looking for an interior angle, you cannot say yet that that angle is pi/2 even if one of its ray is vertical. You still need to find the slope of the other ray that make up the angle.

ray here is side of triangle.
uhm... There will be one max vertical side, i agree.

I said pi/2 because i'm doing the difference between the two angles with x...
Suppose to have a side that lays on a line that have an angle of 60° with the x, and the next side lays on a line that have an angle of 45° with the x...
The interior angle is 15°, right?

Now, if the side is vertical... the angle with the x (I use that angle) is 90°, isn't it?

6. Originally Posted by 3n1gm4
uhm... There will be one max vertical side, i agree.

I said pi/2 because i'm doing the difference between the two angles with x...
Suppose to have a side that lays on a line that have an angle of 60° with the x, and the next side lays on a line that have an angle of 45° with the x...
The interior angle is 15°, right?

Now, if the side is vertical... the angle with the x (I use that angle) is 90°, isn't it?
Yes, you are right.

Of course I did not know that's how you were calling the "angles". I thought the angles were already the interior angles.

In analyzing the interior angles by your method, it is best to consider first the angle made by the side with the x-axis.
So that is why you said earlier that if (x2 -x1) = 0, then the "angle" = pi/2.

Good.

7. Originally Posted by ticbol
Yes, you are right.

Of course I did not know that's how you were calling the "angles". I thought the angles were already the interior angles.

In analyzing the interior angles by your method, it is best to consider first the angle made by the side with the x-axis.
So that is why you said earlier that if (x2 -x1) = 0, then the "angle" = pi/2.

Good.
The problem is that's not working ^_^
Maybe my implementation (in a program) is wrong... but i'm thinking on.. 2 lines generate 2 angles... how can I decide what's the right angle?

could be: $angle = atan(m_1) - atan(m_2)$

or $angle = \frac{\pi - 2[atan(m_1) - atan(m_2)]}{2}$ (the other one)...

is there any CORRECT way to be sure of what angle it is?

ps:
that's the wrong sections, this is not URGENT, sorry, can someone move that?

8. Originally Posted by 3n1gm4
The problem is that's not working ^_^
Maybe my implementation (in a program) is wrong... but i'm thinking on.. 2 lines generate 2 angles... how can I decide what's the right angle?

could be: $angle = atan(m_1) - atan(m_2)$

or $angle = \frac{\pi - 2[atan(m_1) - atan(m_2)]}{2}$ (the other one)...

is there any CORRECT way to be sure of what angle it is?

ps:
that's the wrong sections, this is not URGENT, sorry, can someone move that?
I understand what you mean now. You mean sometimes you are not getting the correct answer at once. Sometimes you are getting a negative angle.

I am not familiar with your method. But in order for you to get the correct interior angle always, why not use the formula so that you will always get a positive interior angle. That is,

1) interior angle = arctan(m1) -actant(m2)
(1a)if m1 is positive and m2 is positive also but less than m1, or
(1b)if m1 is positive and m2 is negative.

2) interior angle = arctan(m2) -actant(m1)
(1a) if m2 is positive and m1 is positive also but less than m2, or
(1b) if m2 is positive and m1 is negative.

3)...
.....Too much explaining....

Well, the idea is to get a positive intreior angle right away by juggling your m1 and m2.
Then to check or to compare the answer to the same angle on the triangle. Are they about the same?

The "other" formula, interior angle = pi/2 -[arctan(m1) -arctan(m2)], might give you also a negative angle sometimes.

9. Originally Posted by ticbol
I understand what you mean now. You mean sometimes you are not getting the correct answer at once. Sometimes you are getting a negative angle.

I am not familiar with your method. But in order for you to get the correct interior angle always, why not use the formula so that you will always get a positive interior angle. That is,

1) interior angle = arctan(m1) -actant(m2)
(1a)if m1 is positive and m2 is positive also but less than m1, or
(1b)if m1 is positive and m2 is negative.

2) interior angle = arctan(m2) -actant(m1)
(1a) if m2 is positive and m1 is positive also but less than m2, or
(1b) if m2 is positive and m1 is negative.

3)...
.....Too much explaining....

Well, the idea is to get a positive intreior angle right away by juggling your m1 and m2.
Then to check or to compare the answer to the same angle on the triangle. Are they about the same?

The "other" formula, interior angle = pi/2 -[arctan(m1) -arctan(m2)], might give you also a negative angle sometimes.
The problem is not the sign but the value. I use absolute value of the angle (no matter what method i used to calculate it).

$abs(arctan(m_2) -actan(m_1)) = abs(arctan(m_1) -actan(m_2))$
That's eliminates some tests ^^...

So... (this image should help)

We have 2 segment that have in common $O(x,y)$
The first segment ends in $P_4(x_4,y_4)$
If the other segment ends in $P_2(x_2,y_2)$ the angle is alpha
but if the other segment ends in $P_1(x_1,y_1)$ the angle is beta... now, how can I choose the calculation method?

EDIT:
I'm trying now Law of Cosines too... but maybe i'm too tired now :O
If someone is good at, here is my source in python, i hope is enough readable.
The input consist in a set of 3 point $x_1,y_1,x_2,y_2,x_3,y_3$ and the output should be something like "isosceles right triangle" or "scalene obtuse triangle" or other classification or "not a triangle" if it is not...

10. Originally Posted by 3n1gm4
The problem is not the sign but the value. I use absolute value of the angle (no matter what method i used to calculate it).

$abs(arctan(m_2) -actan(m_1)) = abs(arctan(m_1) -actan(m_2))$
That's eliminates some tests ^^...

So... (this image should help)

We have 2 segment that have in common $O(x,y)$
The first segment ends in $P_4(x_4,y_4)$
If the other segment ends in $P_2(x_2,y_2)$ the angle is alpha
but if the other segment ends in $P_1(x_1,y_1)$ the angle is beta... now, how can I choose the calculation method?

EDIT:
I'm trying now Law of Cosines too... but maybe i'm too tired now :O
If someone is good at, here is my source in python, i hope is enough readable.
The input consist in a set of 3 point $x_1,y_1,x_2,y_2,x_3,y_3$ and the output should be something like "isosceles right triangle" or "scalene obtuse triangle" or other classification or "not a triangle" if it is not...
Geez, the more we discuss it , the more it becomes confusing. I thought it was just about simple interior angles of a triangle. Are you sure, if we continue discussing this, we are not heading to celestial geometry?

Okay, the absolute values are good idea. So either add or subtract the absolute values to see which result will compare closer to the interior angle in question.

Explaining with numbers is easier understood. Could you give me points whose coordinates are numbers. Let me show you what I mean....before we go to affine geometry or something.

11. Originally Posted by ticbol
Geez, the more we discuss it , the more it becomes confusing. I thought it was just about simple interior angles of a triangle. Are you sure, if we continue discussing this, we are not heading to celestial geometry?
Ahahahah, yes it's only about interior angles

Originally Posted by ticbol
Okay, the absolute values are good idea. So either add or subtract the absolute values to see which result will compare closer to the interior angle in question.

Explaining with numbers is easier understood. Could you give me points whose coordinates are numbers. Let me show you what I mean....before we go to affine geometry or something.

OK i'll try to use some numbers... take a sheet of paper and a pencil :P

Consider these points:
$O(0,0)$, $A(2,4)$, $B(-2,2)$, $C(2,-2)$

The triangle $AOB$ and $AOC$ have in common the side $\overline{OA}$. Points $B$, $O$ and $C$ lay on the same line (so $\overline{BO}$ and $\overline{OA}$ have the same slope).

How to calculate the angle $\widehat{AOB}$ and the angle $\widehat{AOC}$ ??

Can we project a formula (or a process) based on coordinates of 3 points (the one in common, in this case $O$, plus the other two) ?

12. I don't see how this is complicated. Given the 3 points, use the distance formula ( $d = \sqrt{(x2-x1)^2 + (y2-y1)^2}$ ) to find the length of the three side of the triangles, then find the angles using the Law of Cosines. I assume you need to classify it as scalene, isosceles, or equilateral. If you're having trouble understanding the Law of Cosines, do let us know.

13. Originally Posted by Chop Suey
I don't see how this is complicated. Given the 3 points, use the distance formula (d = sqrt( (x2-x1)^2 + (y2-y1)^2 ) to find the length of the three side of the triangles, then find the angles using the Law of Cosines. I assume you need to classify it as scalene, isosceles, or equilateral. If you're having trouble understanding the Law of Cosines, do let us know.
I already did this, but the sum does not return $\pi$
maybe is wrong my implementation.... but i don't know... i'm using (calling a,b,c length of sides):
$alpha = acos(\frac{c^2 + b^2 -a^2}{2cb})$
$beta = acos(\frac{c^2 + b^2 -b^2}{2ac})$
$gamma = acos(\frac{a^2 + b^2 -c^2}{2ab})$

Ok, converting formulas to latex i see an error on beta (damn copy and paste)... i'll work on it and let you know :O

14. Originally Posted by 3n1gm4
Ahahahah, yes it's only about interior angles

OK i'll try to use some numbers... take a sheet of paper and a pencil :P

Consider these points:
$O(0,0)$, $A(2,4)$, $B(-2,2)$, $C(2,-2)$

The triangle $AOB$ and $AOC$ have in common the side $\overline{OA}$. Points $B$, $O$ and $C$ lay on the same line (so $\overline{BO}$ and $\overline{OA}$ have the same slope).

How to calculate the angle $\widehat{AOB}$ and the angle $\widehat{AOC}$ ??

Can we project a formula (or a process) based on coordinates of 3 points (the one in common, in this case $O$, plus the other two) ?
m1 = slope of OA = (4-0)/(2-0) = 2
m2 = slope of BOC = (-2 -2)/(2 -(-2)) = -1

So the angle OA makes with the x-axis is arctan(2) = 63.4395 degrees
And the angle BOC makes with the x-axis is arctan(-1) = -45 degrees.

If I use what I explained before that get always a positive answer, then both angle AOB and angle AOC will come out 108.4395 degrees each. Which is wrong.

If we use you absolute values, angle AOB and angle AOC will either be 18.4395 deg or -18.4395 deg.

So we forget both ways. Both are not reliable.

Here is where comparison to the figure/diagram/sketch is very useful.

In my sketch, handrawn but fairly up to scale,
angle AOB looks like less than 90 degrees
angle AOC looks like greater than 90 degrees

So, angle AOB = 63.4395 -45 = 18.4395 degrees...?
Cannot be. In the sketch, it is bigger than that.
So, angle AOB = 90 -18.4395 = 71.5605 deg.

Angle AOC = 63.4395 +45 = 108.4395 deg.
In the sketch, it looks like that.
So, angle AOC = 108.4395 deg.

-------------
I don't like your method. Maybe that's why it was not taught to us when I was yet a student.

I'd use the method using Law of Cosines always.

15. Yes, I got the same answers as yours ticbol. The sum of the answers returns pi.

Are you sure you're using Law of Cosines correctly, Enigma?

Label the vertices of one triangle A, B, C. The side opposite the vertex will be labeled as the lowercase letter of the vertex. For instance, if you're to find angle A, use the following:

$a^2 = b^2 + c^2 - 2bc \cos{A}$

Image:Triangle with notations.svg - Wikimedia Commons

Page 1 of 2 12 Last