Class: Sphere
Instance Attribute Summary
Attributes inherited from HyperSphere
#center, #pct_error, #radius
Instance Method Summary
collapse
Methods inherited from HyperSphere
#equation, #help, help, #how_far, #inside?, #on?, #outside?
Constructor Details
#initialize(radius = 1, center = [0,0,0], pct_error = 1) ⇒ Sphere
Returns a new instance of Sphere.
5
6
7
|
# File 'lib/zadt/AbstractDataTypes/Geometrics/sphere.rb', line 5
def initialize(radius = 1, center = [0,0,0], pct_error = 1)
super(radius, center, pct_error)
end
|
Instance Method Details
#inspect ⇒ Object
19
20
21
|
# File 'lib/zadt/AbstractDataTypes/Geometrics/sphere.rb', line 19
def inspect
"Sphere: #{equation}"
end
|
#surface_area ⇒ Object
14
15
16
17
|
# File 'lib/zadt/AbstractDataTypes/Geometrics/sphere.rb', line 14
def surface_area
dim_check(3)
4.0 * Math::PI * (@radius ** 2)
end
|
#volume ⇒ Object
9
10
11
12
|
# File 'lib/zadt/AbstractDataTypes/Geometrics/sphere.rb', line 9
def volume
dim_check(3)
Math::PI * (@radius ** 3) * 4.0 / 3.0
end
|