Class: Mageo::Polar3D
Overview
3次元極座標。 極座標ライブラリでは、角度は基本的に radian を使用する。 degree は人間の都合で決められた尺度だろう。 まあ人間用に degree 用インターフェイスも用意することもあるかもしれんが。
Instance Attribute Summary collapse
-
#phi ⇒ Object
readonly
Returns the value of attribute phi.
-
#r ⇒ Object
readonly
Returns the value of attribute r.
-
#theta ⇒ Object
readonly
Returns the value of attribute theta.
Instance Method Summary collapse
-
#initialize(r, theta, phi) ⇒ Polar3D
constructor
A new instance of Polar3D.
-
#minimize_phi ⇒ Object
phi を 0 <= phi < 2*PI の間の角度に変換したオブジェクトを返す非破壊破壊的メソッド。.
-
#minimize_phi! ⇒ Object
phi を 0 <= phi < 2*PI の間の角度に変換する破壊破壊的メソッド。.
-
#to_v3d ⇒ Object
3次元 Vector に変換。.
Constructor Details
#initialize(r, theta, phi) ⇒ Polar3D
Returns a new instance of Polar3D.
15 16 17 18 19 |
# File 'lib/mageo/polar3d.rb', line 15 def initialize( r, theta, phi) @r = r @theta = theta @phi = phi end |
Instance Attribute Details
#phi ⇒ Object (readonly)
Returns the value of attribute phi.
12 13 14 |
# File 'lib/mageo/polar3d.rb', line 12 def phi @phi end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
12 13 14 |
# File 'lib/mageo/polar3d.rb', line 12 def r @r end |
#theta ⇒ Object (readonly)
Returns the value of attribute theta.
12 13 14 |
# File 'lib/mageo/polar3d.rb', line 12 def theta @theta end |
Instance Method Details
#minimize_phi ⇒ Object
phi を 0 <= phi < 2*PI の間の角度に変換したオブジェクトを返す非破壊破壊的メソッド。
38 39 40 41 42 |
# File 'lib/mageo/polar3d.rb', line 38 def minimize_phi result = Marshal.load( Marshal.dump( self ) ) result.minimize_phi! result end |
#minimize_phi! ⇒ Object
phi を 0 <= phi < 2*PI の間の角度に変換する破壊破壊的メソッド。
31 32 33 34 35 |
# File 'lib/mageo/polar3d.rb', line 31 def minimize_phi! tmp = ( @phi / (2.0*PI) ) tmp = tmp - tmp.floor @phi = (2.0*PI) * tmp end |