Class: RedEye::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/morandi/redeye.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#area_min_xObject

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_yObject

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

#centreObject



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