是否有C语言函数来计算度/弧度? [英] Is there a function in C language to calculate degrees/radians?
本文介绍了是否有C语言函数来计算度/弧度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要计算用C PROGRAMM的角度。下面是JAVA的方法,我需要转换为C。
私有静态双calculateDirection(双X,双Y)
{
返回Math.toDegrees(Math.atan2(Y,X));
}
有没有像在C语言中toDegrees一个函数,所以我没有写我自己所有的code?
谢谢
解决方案
的#include<&math.h中GT;内嵌双to_degrees(双弧度){
返回弧度*(180.0 / M_PI);
}
I need to calculate an angle in C programm. Here is a method from JAVA that I need to convert to C.
private static double calculateDirection(double x, double y)
{
return Math.toDegrees(Math.atan2(y, x));
}
Is there a function like toDegrees in C language so I don't have to write all the code by myself? Thank you
解决方案
#include <math.h>
inline double to_degrees(double radians) {
return radians * (180.0 / M_PI);
}
这篇关于是否有C语言函数来计算度/弧度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文