acos not working properly

Hey,
I'm writing a programm to create some random triangles and after creating the lengths a,b and c (a+b > c && a < c && b < c) i want to get the angles with the sss cosinus formula. I need the acos function, but for example:

acos(-0.2) throws out 1.77215 , but on my calculator its 102 (101.5).


Am I missing something ?
Actually it is working fine, just that 1.77215 is in radians, while 101.5 is in degrees.

Here's how to quickly transform radians into degrees:

1
2
3
4
5
6
7
8
9
10
11
#include<cmath>
#include<iostream>

int main()
{
  float PI=3.1415;
  std::cout<<acos(-0.2) * 180/PI;

  return 0;
}


Output
101.54
Last edited on
Thank you for the quick answer!

Perfect
Topic archived. No new replies allowed.