C语言中怎么计算三角函数?全部的程序代码?

C语言中怎么计算三角函数?全部的程序代码?,第1张

math.h里的三角函数用的单位是弧度,你貌似错在这里。   答案补充 Example

/* SINCOS.C: This program displays the sine, hyperbolic

* sine, cosine, and hyperbolic cosine of pi / 2.

*/

#include <math.h>

#include <stdio.h>

void main( void )

{

double pi = 3.1415926535

double x, y

x = pi / 2

y = sin( x )

printf( "sin( %f ) = %f\n", x, y )

y = sinh( x )

printf( "sinh( %f ) = %f\n",x, y )

y = cos( x )

printf( "cos( %f ) = %f\n", x, y )

y = cosh( x )

printf( "cosh( %f ) = %f\n",x, y )

}  答案补充 Output

sin( 1.570796 ) = 1.000000

sinh( 1.570796 ) = 2.301299

cos( 1.570796 ) = 0.000000

cosh( 1.570796 ) = 2.509178

Parameter

x

Angle in radians

根据Math.cos和Math.sin来实现不同的方位判断。

主要根据下面函数来计算:

var angleRadians:Number = angle * Math.PI / 180//换算成弧度

var p:Point = new Point(Math.cos(angleRadians) * RADIUS, Math.sin(angleRadians) * RADIUS)//计算偏移量

扩展资料

C语言提供了以下的数学函数,要使用这些函数时,在程序文件头必须加入:

<math.h >

函数说明

double sin(double x)

x 的正弦函数值

double cos(double x)

x的余弦函数值

double tan(double x)

x 的正切函数值

double asin(double x)

x 的反正弦函数值 sin-1x,x的值在 [-1,1] 之间,传回的值在 [-p/2,p/2] 之间

double acos(double x)

x 的反余弦函数值cos-1x,x的值在 [-1,1] 之间,传回的值在 [-p/2,p/2] 之间

double atan(double x)

x 的反正切函数值tan-1x,传回的值在 [-p/2,p/2] 之间

double atan2(double y, double x)

y/x 的反正切函数值tan-1(y/x),传回的值在 [-p, p] 之间

参考资料来源:

百度百科——math.h


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8057386.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-13
下一篇2023-04-13

发表评论

登录后才能评论

评论列表(0条)

    保存