Hi, i am doing an assignment that requires me to determine if a triangle is a right triangle, acute or obtuse given 3 points. So far I calculated the sides of the triangle given the points. I am not trying to calculate the angles given the sides, but when I output the angles (given random points) I get -nan(ind). I am not sure what this means or what i am doing wrong. Here is my code so far:
- Inverting the cosine rule requires you to bracket more carefully: cos A = ( b2 + c2 - a2 ) / (2bc)
so A = acos( ( b2 + c2 - a2 ) / (2bc) )
- Trigonometric functions in any serious scientific programming language work in radians, not degrees, so angle_C = 180 - angle_A - angle_B;
won't work unless you either convert the angles on the right hand side to degrees or replace the 180 by 2.pi