class Circle
Public Class Methods
help()
click to toggle source
# File lib/zadt/HelpModules/Functionality/Geometrics/circle.rb, line 8 def self.help Circle.show_help_message end
new(radius = 1, center = [0,0], pct_error = 1)
click to toggle source
Calls superclass method
HyperSphere::new
# File lib/zadt/AbstractDataTypes/Geometrics/circle.rb, line 5 def initialize(radius = 1, center = [0,0], pct_error = 1) 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/circle.rb, line 14 def self.show_help_message super Zadt::ADT::show_circle_help_message end
Public Instance Methods
area()
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/circle.rb, line 9 def area dim_check(2) Math::PI * (@radius ** 2) end
circumference()
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/circle.rb, line 14 def circumference dim_check(2) 2 * Math::PI * @radius end
help()
click to toggle source
# File lib/zadt/HelpModules/Functionality/Geometrics/circle.rb, line 4 def help Circle.help end
inspect()
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/circle.rb, line 19 def inspect "Circle: #{equation}" end
Private Instance Methods
circle_equation()
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/circle.rb, line 25 def circle_equation dim_check(2) center_point = @center.dup coord_names = ["x", "y"] center_point.coords.each_with_index do |center_coord, index| if center_coord == 0 # coord_name is fine elsif center_coord < 0 coord_names[index] = "(#{coord_names[index]} + #{-center_coord})" else coord_names[index] = "(#{coord_names[index]} - #{center_coord})" end end "#{coord_names[0]}^2 + #{coord_names[1]}^2 = #{@radius ** 2}" end
close_enough(guess, exact)
click to toggle source
# File lib/zadt/AbstractDataTypes/Geometrics/circle.rb, line 41 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