1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHPで三角関数を計算する(度数法、弧度法)

Posted at

PHPで三角関数の正弦、余弦、正接を計算するにはsin(), cos(), tan()関数を用います。
この際に指定する角度は弧度法(ラジアン)となっています。
度数法で表現された角度をラジアンに変換するためには、deg2rad()関数を用います。

たとえば、度数法で30°の正弦、余弦、正接を表示するスクリプトは以下のようになります。

$degree = 30; //度数法による角度
$radian = deg2rad($degree); //弧度法による角度
print sin($radian) . "\n"; //0.5
print cos($radian) . "\n"; //0.86602540378444
print tan($radian) . "\n"; //0.57735026918963

参考:
PHP: sin - Manual https://www.php.net/manual/ja/function.sin.php
PHP: cos - Manual https://www.php.net/manual/ja/function.cos.php
PHP: tan - Manual https://www.php.net/manual/ja/function.tan.php
PHP: deg2rad - Manual https://www.php.net/manual/ja/function.deg2rad.php

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?