Class: Geometry::BoundingBox

Inherits:
Struct
  • Object
show all
Defined in:
lib/geometry/bounding_box.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#leftbottomObject

Returns the value of attribute leftbottom

Returns:

  • (Object)

    the current value of leftbottom


2
3
4
# File 'lib/geometry/bounding_box.rb', line 2

def leftbottom
  @leftbottom
end

#righttopObject

Returns the value of attribute righttop

Returns:

  • (Object)

    the current value of righttop


2
3
4
# File 'lib/geometry/bounding_box.rb', line 2

def righttop
  @righttop
end

Instance Method Details

#contains?(point) ⇒ Boolean

Returns:

  • (Boolean)

7
8
9
# File 'lib/geometry/bounding_box.rb', line 7

def contains?(point)
  point.x.between?(leftbottom.x, righttop.x) && point.y.between?(leftbottom.y, righttop.y)
end

#diagonalObject


3
4
5
# File 'lib/geometry/bounding_box.rb', line 3

def diagonal
  Segment leftbottom, righttop
end