Class: Moon::SAT::Circle

Inherits:
Object show all
Defined in:
lib/moon/packages/physics/sat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pos = Moon::Vector2.zero, r = 0) ⇒ Circle

Returns a new instance of Circle.


136
137
138
139
# File 'lib/moon/packages/physics/sat.rb', line 136

def initialize(pos = Moon::Vector2.zero, r = 0)
  @position = pos
  @radius = r
end

Instance Attribute Details

#positionMoon::Vector2

Returns:


130
131
132
# File 'lib/moon/packages/physics/sat.rb', line 130

def position
  @position
end

#radiusInteger Also known as: r

Returns:


132
133
134
# File 'lib/moon/packages/physics/sat.rb', line 132

def radius
  @radius
end

Instance Method Details

#aabbObject


141
142
143
144
# File 'lib/moon/packages/physics/sat.rb', line 141

def aabb
  corner = position - [r, r]
  Box.new(corner, r * 2, r * 2).to_polygon
end