C语言中arctan()函数的使用示例有哪些

   2024-10-01 7900
核心提示:计算角度的反正切值:#include stdio.h#include math.hint main() {double angle = 45.0;double result = atan(angle * M_PI / 1

计算角度的反正切值:

#include <stdio.h>#include <math.h>int main() {    double angle = 45.0;    double result = atan(angle * M_PI / 180); // 将角度转换为弧度    printf("The arctan of %f is %f radians\n", angle, result);    return 0;}
计算直角三角形的角度值:
#include <stdio.h>#include <math.h>int main() {    double adjacent = 3.0;    double opposite = 4.0;    double angle = atan(opposite / adjacent) * 180 / M_PI; // 计算反正切值并将弧度转换为角度    printf("The angle of the right triangle is %f degrees\n", angle);    return 0;}
计算两点之间的夹角:
#include <stdio.h>#include <math.h>int main() {    double x1 = 1.0, y1 = 1.0;    double x2 = 2.0, y2 = 2.0;        double angle = atan((y2 - y1) / (x2 - x1)) * 180 / M_PI; // 计算两点之间的夹角    printf("The angle between the two points is %f degrees\n", angle);    return 0;}

 
举报打赏
 
更多>同类物流大全
推荐图文
推荐物流大全
点击排行

网站首页  |  关于我们  |  联系方式 | 网站留言    |  赣ICP备2021007278号