Class: EhbGameLib::Math::Circle

Inherits:
Object
  • Object
show all
Defined in:
lib/ehb_game_lib/math/circle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cx, cy, radius) ⇒ Circle

Returns a new instance of Circle.



8
9
10
11
# File 'lib/ehb_game_lib/math/circle.rb', line 8

def initialize(cx, cy, radius)
  @center = Vector.new(cx, cy)
  @radius = radius
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



6
7
8
# File 'lib/ehb_game_lib/math/circle.rb', line 6

def center
  @center
end

#radiusObject (readonly)

Returns the value of attribute radius.



6
7
8
# File 'lib/ehb_game_lib/math/circle.rb', line 6

def radius
  @radius
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/ehb_game_lib/math/circle.rb', line 13

def to_s
  "C: #{center}, R: #{radius}"
end

#ys(x) ⇒ Object



17
18
19
# File 'lib/ehb_game_lib/math/circle.rb', line 17

def ys(x)
  QuadraticEquation.new(1, -2 * cy, ys_c(x)).roots
end