るりまサーチ

最速Rubyリファレンスマニュアル検索!
77件ヒット [1-77件を表示] (0.082秒)
トップページ > クエリ:-[x] > クエリ:Numeric[x] > クエリ:polar[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

クラス

キーワード

検索結果

Numeric (40320.0)

数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。

...ラス
Numeric のサブクラスとして実装されています。

演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッドは、サブクラスで提供されているメソッド
(+, -, *, /, %)...
...を利用して定義されるものがほとんどです。
つまり Numeric で定義されているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce)だけを定義すれば、数値クラスのそ...
...d? | - o o o - - -
ord | - o - - - - -
phase | o - - - o - o
polar
|...
...- - -
Numeric
Integer Float Rational Complex
-
-------------------------------------------------------------------------------
phase | o - o - o
polar
|...

Numeric#polar -> [Numeric, Numeric] (39451.0)

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

...。正の数なら [self, 0]、負の数な
ら [-self, Math::PI] を返します。

//emlist[例][ruby]{
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 Complex#polar...

Complex#polar -> [Numeric, Numeric] (18427.0)

自身の絶対値と偏角を配列にして返します。

...自身の絶対値と偏角を配列にして返します。

//emlist[例][ruby]{
Complex.polar(1, 2).polar # => [1, 2]
//}

@see Numeric#polar...

Complex#angle -> Float (160.0)

自身の偏角を[-π,π]の範囲で返します。

...を[-π,π]の範囲で返します。

//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}

非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-
0.0 では値が変わります。

//emlist[例][ruby]{
Complex(-1, 0)...
...793
Complex(-1, -0).arg #=> 3.141592653589793
Complex(-1, -0.0).arg #=> -3.141592653589793

Complex(0, 0.0).arg #=> 0.0
Complex(0, -0.0).arg #=> -0.0
Complex(-0.0, 0).arg #=> 3.141592653589793
Complex(-0.0, -0.0).arg #=> -3.141592653...
...589793
//}


@see Numeric#arg...

Complex#arg -> Float (160.0)

自身の偏角を[-π,π]の範囲で返します。

...を[-π,π]の範囲で返します。

//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}

非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-
0.0 では値が変わります。

//emlist[例][ruby]{
Complex(-1, 0)...
...793
Complex(-1, -0).arg #=> 3.141592653589793
Complex(-1, -0.0).arg #=> -3.141592653589793

Complex(0, 0.0).arg #=> 0.0
Complex(0, -0.0).arg #=> -0.0
Complex(-0.0, 0).arg #=> 3.141592653589793
Complex(-0.0, -0.0).arg #=> -3.141592653...
...589793
//}


@see Numeric#arg...

絞り込み条件を変える

Complex#phase -> Float (160.0)

自身の偏角を[-π,π]の範囲で返します。

...を[-π,π]の範囲で返します。

//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}

非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-
0.0 では値が変わります。

//emlist[例][ruby]{
Complex(-1, 0)...
...793
Complex(-1, -0).arg #=> 3.141592653589793
Complex(-1, -0.0).arg #=> -3.141592653589793

Complex(0, 0.0).arg #=> 0.0
Complex(0, -0.0).arg #=> -0.0
Complex(-0.0, 0).arg #=> 3.141592653589793
Complex(-0.0, -0.0).arg #=> -3.141592653...
...589793
//}


@see Numeric#arg...

Complex (42.0)

複素数を扱うクラスです。

...el.#Complex、
Complex.rect、Complex.polarNumeric#to_c、
String#to_c のいずれかを使用します。

//emlist[Complex オブジェクトの作り方][ruby]{
Complex(1) # => (1+0i)
Complex(2, 3) # => (2+3i)
Complex.polar(2, 3) # => (-1.9799849932008908+0.2822400161197344i...
...# => (0.3+0i)
Complex('0.3-0.5i') # => (0.3-0.5i)
Complex('2/3+3/4i') # => ((2/3)+(3/4)*i)
Complex('1@2') # => (-0.4161468365471424+0.9092974268256817i)
3.to_c # => (3+0i)
0.3.to_c # => (0.3+0i)
'0.3-0.5i'.to_c # => (0.3-0.5i)
'2/3+3/4i'.to_c # => (...
...(2/3)+(3/4)*i)
'1@2'.to_c # => (-0.4161468365471424+0.9092974268256817i)
//}

Complex オブジェクトは有理数の形式も実数の形式も扱う事ができます。

//emlist[例][ruby]{
Complex(1, 1) / 2 # => ((1/2)+(1/2)*i)
Complex(1, 1) / 2.0 # => (0.5+0.5i)
//}...