get angle from sin and cos
I have two value : sin(a) and cos(a).
I want to get angle value (degree or radian) for a.
What functions (C++) should i use to get a?
asin and acos will return you the angle, but you may need to evaluate both since, for example, you get the same value when evaluating sin50 and sin130 (and asin will always return 50). So, you evaluate both and check wether they're positive/negative and make the appropiate corrections.
Saludos,
José Jorge (GeoMX).
Saludos,
José Jorge (GeoMX).
You can either use asin() or acos(), but I recommend using atan2(). Example:
float s = sin(angle);
float c = cos(angle);
float angle = atan2(s, c);
This makes sure you get the right sign of the angle. This is also very helpful when working with quaternions...
HTH,
-Dirk
float s = sin(angle);
float c = cos(angle);
float angle = atan2(s, c);
This makes sure you get the right sign of the angle. This is also very helpful when working with quaternions...
HTH,
-Dirk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement