Class: RedEye::Region
- Inherits:
-
Object
- Object
- RedEye::Region
- Defined in:
- lib/morandi/redeye.rb
Instance Attribute Summary collapse
-
#area_min_x ⇒ Object
Returns the value of attribute area_min_x.
-
#area_min_y ⇒ Object
Returns the value of attribute area_min_y.
Instance Method Summary collapse
- #centre ⇒ Object
-
#distance_from(x, y) ⇒ Object
Pythagorean.
Instance Attribute Details
#area_min_x ⇒ Object
Returns the value of attribute area_min_x.
45 46 47 |
# File 'lib/morandi/redeye.rb', line 45 def area_min_x @area_min_x end |
#area_min_y ⇒ Object
Returns the value of attribute area_min_y.
46 47 48 |
# File 'lib/morandi/redeye.rb', line 46 def area_min_y @area_min_y end |
Instance Method Details
#centre ⇒ Object
47 48 49 50 |
# File 'lib/morandi/redeye.rb', line 47 def centre [@area_min_x.to_i + ((maxX + minX) >> 1), @area_min_y.to_i + ((maxY + minY) >> 1)] end |
#distance_from(x, y) ⇒ Object
Pythagorean
53 54 55 56 57 58 59 60 |
# File 'lib/morandi/redeye.rb', line 53 def distance_from(x,y) cx,cy = centre() dx = cx - x dy = cy - y Math.sqrt( (dx * dx) + (dy * dy) ) end |