Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Numericクラス > polar

instance method Numeric#polar

polar -> [Numeric, Numeric][permalink][rdoc]

自身の絶対値と偏角を配列にして返します。正の数なら [self, 0]、負の数なら [-self, Math::PI] を返します。



1.0.polar  # => [1.0, 0]
2.0.polar  # => [2.0, 0]
-1.0.polar # => [1.0, 3.141592653589793]
-2.0.polar # => [2.0, 3.141592653589793]

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

[SEE_ALSO] Complex#polar