2024/02/13 22:13:39

Perl 標準関数: atan2

atan2

atan2 Y,X

Returns the arctangent of Y/X in the range -PI to PI. For the tangent operation, you may use the "Math::Trig::tan" function, or use the familiar relation:

sub tan { sin($_[0]) / cos($_[0])  }

atan2 関数は、Y, X の2引数をとり、-π~πの範囲でアークタンジェント(逆正接)を返します。 タンジェント(正接)を扱いたいなら、Math::Trig::tan を利用するか、次の関数を用います。

sub tan { sin($_[0]) / cos($_[0])  }

atan2 サンプルコード

print atan2(1, 1); # 0.785398163397448 (PI/4)
サイト内検索