C言語 逆三角関数 - math.h - [ asin, acos, atan, atan2 ]

2008.08.30 Saturday | by LRESULT


三角関数の計算には、asin()、acos()、atan()、atan2()を使います。


asin
書式 double asin( double x )
機能 アークサインの計算
引数 double x : -1~1のサイン値
戻り値 アークサイン値(ラジアン)




acos
書式 double acos( double x )
機能 アークコサインの計算
引数 double x : -1~1のコサイン値
戻り値 アークコサイン値(ラジアン)




atan
書式 double atan( double x )
機能 アークタンジェントの計算
引数 double x : -π/2~π/2のタンジェント値
戻り値 アークタンジェント値(ラジアン)




atan2
書式 double atan2( double y, double x )
機能 y/x のアークタンジェントの計算
引数 double y : y座標
double x : x座標
戻り値 アークタンジェント値(ラジアン)





サンプルコード
三角関数の逆関数となっている為、
ラジアンをコサインした後、アークコサインして、値が同じかどうか見てみます。
#include <stdio.h>
#include <math.h>

#define
PI 3.141592

int
main(void)
{
  double deg = 30;

  double rad = deg * PI / 180.0;
  printf( "rad = %f¥n", rad );

  double c = cos( rad );
  double a = acos( c );
  printf( "acos = %f¥n", a );

  return 0;
}



結果
rad = 0.523599
acos = 0.523599
と同じ値になります。

カテゴリ:C言語 math.h | 21:02 | comments(1) | trackbacks(0) | -


コメント

管理者の承認待ちコメントです。

| - | 2012/11/27 3:15 PM |

コメントする











この記事のトラックバックURL

トラックバック機能は終了しました。

トラックバック