我正在寻找一种将小数转换为 C 中的度数的方法。例如,C 中的 asin() 函数返回一个十进制数,但我需要该数字以度数 ° 分 ' 秒为单位“。
例如1.5 将是 1°30'0"
最佳答案
asin
函数返回弧度。一个圆有 2 π 弧度。
一个圆有360度,一个度有60分,一分有60秒。所以一圈有360*60*60秒。
double radians = asin(opposite / hypotenuse);
int totalSeconds = (int)round(radians * 360 * 60 * 60 / (2 * M_PI));
int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int degrees = totalSeconds / (60 * 60);
关于将弧度转换为度、分和秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10360534/