Sign in to follow this  
grumpyOldDude

Angle check calculations

Recommended Posts

Hello
My code requires that I calculate the length and angles of certain triangles using the basic sine rule:  
                                                                                             a/sin(a)   =   b/sin(b)     =  e/sin(e),    
 
Mostly the calculated angle beta could be  0 <= beta <= 90      but sometimes it could be      90 < beta <= 180
 
Whereas sine beta  is always                    0 <= sine(beta) <= 1   which is always  0 < beta <= 90.  
 
So that means sometimes I have 2 answers for the angle as shown in the diagram. Because i'm running every thing progrmmatically i can't check the triangle visually or graphically to do know if beta should be....                                                                                                        
                                                                                       beta  =   beta                                                                                                                                                                                                                                                                   OR                beta  =   180 - beta
 
as in this example,  diagram below                                    beta  = 67.1   or  180 - 67.1 = 112.9.        
 
I'm not able to check this visually or graphically, I've got to check it programatically - ie in code by calculations only, but I don't know to make this check by calculation ( i don't need a code but the calculations on how to do this )
So how can I do this actual calculation check? Once i understand the calculation check then I can code it, so the coding is not the problem but the calculation check            
                              [attachment=29291:sine rule on triangles3.png]
Edited by alwaysGrey

Share this post


Link to post
Share on other sites

sin/cos only works for triangles with one rectangular corner, ie 90 degrees.

 

From your example, it looks like you will need to split your triangle into 2 triangles with a rectangular corner, eg from the left figure, draw a line through P perpendicular to the line QR.

Not sure this would work, but it looks like a nice approach to try.

 

Edit: At the right figure you could drop straight down from Q, and extend PR at the 'R' side. This is likely the second case that you'll get.

Edited by Alberth

Share this post


Link to post
Share on other sites

it looks like you will need to split your triangle into 2 triangles with a rectangular corner, eg from the left figure, draw a line through P perpendicular to the line QR.

 

Thanks for reply.  I can't know which triangles to split until my code checks it, because the code is going to be reading the triangle data and making the angle calculations. Some triangles would have an obtuse angle some won't, but i've got to find a calculation way  to test the angles to know if it  is 180-beta or just beta in the progam

 

 

 

sin/cos only works for triangles with one rectangular corner, ie 90 degrees.

Did you mean less than 90 degrees because with the formula in the OP non of the angles have to be 90 degrees 

Edited by alwaysGrey

Share this post


Link to post
Share on other sites

Hmm, right.

 

Pondering about the problem some more, I can see one way to do it. If you look at the right figure, and project Q onto the line PR, the third corner Q is further away from P than R. I think that is a requirement for > 90 degrees at R (exactly 90 degrees would put Q on top of R, less than 90 degrees would put Q to the left of R.

 

Obviously, the latter means Q may be to the left of P (if P > 90 degrees).

In general, this can probably be done by taking one point, setting up a line through the second point, and then projecting the third point onto the line, and checking the distances from the first to the second, and the first to the third point. Then you know the angle of the second point to be bigger or less than 90 degrees.

It does need the coordinates of all corner points though.

Edited by Alberth

Share this post


Link to post
Share on other sites

Do you know if the dot product of two vectors can give angles greater than cosine 90 ?

 

for instance if i do             dotproduct (  PR, QR );  with both triangles would I have the same value or would the triangle on the right give a negative value?

Edited by alwaysGrey

Share this post


Link to post
Share on other sites

It is worth remembering that, by definition, in Euclidean space the interior angles of a triangle add up to exactly 180 degrees.

 

You should also be able to determine whether the angle is acute or obtuse by clever use of the Pythagorean theorem.

Share this post


Link to post
Share on other sites

You should also be able to determine whether the angle is acute or obtuse by clever use of the Pythagorean theorem

 

those irregular triangles don't have to have right-angles, so can't see how i can use Pythagorean theorem (in this particular case).

 

What i ve come with, is to do a dot-product using the vectors of the triangle-sides, then use the signs of the cosine(angle) to check if its obtuse or acute.

 

Since  cosine(acuteAngle) is always positive and  cosine(180-acuteAngle) is always negative

Edited by alwaysGrey

Share this post


Link to post
Share on other sites

Regarding Pythagoras:

 

Take the sum of the squares of the two sides adjacent to the angle in question (a2+b2), and compare it to the square of the opposite side (c2).

From the Pythagorean theorem, you know that if a2+b2=c2 the angle is exactly 90 degrees.

As the opposite side gets shorter, the angle gets more acute (law of sines proves this). Therefore if a2+b2>c2 the angle is less than 90 degrees.

From there it should be obvious that if a2+b2<c2 the angle is greater than 90 degrees.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this