class GSS::PolarPoint
Attributes
phi[R]
theta[R]
Public Class Methods
from_cartesian(x, y, z)
click to toggle source
# File lib/gss/polar_point.rb, line 21 def self.from_cartesian(x, y, z) theta = Math.acos(z / Math.sqrt(x * x + y * y + z * z)) phi = Math.atan2(y, x) self.new(theta, phi) end
new(theta, phi)
click to toggle source
# File lib/gss/polar_point.rb, line 9 def initialize(theta, phi) @theta = theta @phi = phi end
Public Instance Methods
to_cartesian()
click to toggle source
# File lib/gss/polar_point.rb, line 14 def to_cartesian x = Math.sin(@theta) * Math.cos(@phi) y = Math.sin(@theta) * Math.sin(@phi) z = Math.cos(@theta) [x, y, z] end