class Sphere
Public Class Methods
new(radius = 1, center = [0,0,0], pct_error = 1)
click to toggle source
Calls superclass method
HyperSphere::new
# File lib/zadt/AbstractDataTypes/Geometrics/sphere.rb, line 5 def initialize(radius = 1, center = [0,0,0], pct_error = 1) raise "Sphere must be in 3-dimensions" unless center.length == 3 super(radius, center, pct_error) end
Private Class Methods
show_help_message()
click to toggle source
Calls superclass method
HyperSphere::show_help_message
# File lib/zadt/HelpModules/Functionality/Geometrics/sphere.rb, line 7 def self.show_help_message super Zadt::ADT::show_sphere_help_message end
Public Instance Methods
inspect()
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/sphere.rb, line 19 def inspect "Sphere: #{equation}" end
surface_area()
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/sphere.rb, line 14 def surface_area dim_check(3) 4.0 * Math::PI * (@radius ** 2) end
volume()
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/sphere.rb, line 10 def volume Math::PI * (@radius ** 3) * 4.0 / 3.0 end
Private Instance Methods
close_enough(guess, exact)
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/sphere.rb, line 25 def close_enough(guess, exact) range = Array.new range[0] = exact *(100.0 - @pct_error)/100.0 range[1] = exact * (100.0 + @pct_error)/100.0 guess.between?(range[0], range[1]) end