Angle check calculations
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.
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
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.
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?
Sorry, I would have to look up what "dot product" means again (not doing enough 2d/3d math obviously :) )
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.
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
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.