Class: Topolys::BoundingBox

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

Overview

Plane3D

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tol = 0.001) ⇒ BoundingBox

Returns a new instance of BoundingBox.



323
324
325
326
327
328
329
330
331
# File 'lib/topolys/geometry.rb', line 323

def initialize(tol = 0.001)
  @tol = tol
  @minx = Float::INFINITY
  @miny = Float::INFINITY
  @minz = Float::INFINITY
  @maxx = -Float::INFINITY
  @maxy = -Float::INFINITY
  @maxz = -Float::INFINITY
end

Instance Attribute Details

#maxxObject (readonly)

Returns the value of attribute maxx.



321
322
323
# File 'lib/topolys/geometry.rb', line 321

def maxx
  @maxx
end

#maxyObject (readonly)

Returns the value of attribute maxy.



321
322
323
# File 'lib/topolys/geometry.rb', line 321

def maxy
  @maxy
end

#maxzObject (readonly)

Returns the value of attribute maxz.



321
322
323
# File 'lib/topolys/geometry.rb', line 321

def maxz
  @maxz
end

#minxObject (readonly)

Returns the value of attribute minx.



321
322
323
# File 'lib/topolys/geometry.rb', line 321

def minx
  @minx
end

#minyObject (readonly)

Returns the value of attribute miny.



321
322
323
# File 'lib/topolys/geometry.rb', line 321

def miny
  @miny
end

#minzObject (readonly)

Returns the value of attribute minz.



321
322
323
# File 'lib/topolys/geometry.rb', line 321

def minz
  @minz
end

Instance Method Details

#add_point(point) ⇒ Object



333
334
335
336
337
338
339
340
# File 'lib/topolys/geometry.rb', line 333

def add_point(point)
  @minx = [point.x, @minx].min
  @miny = [point.y, @miny].min
  @minz = [point.z, @minz].min
  @maxx = [point.x, @maxx].max
  @maxy = [point.y, @maxy].max
  @maxz = [point.z, @maxz].max
end

#include?(point) ⇒ Boolean

Returns:

  • (Boolean)


342
343
344
345
346
347
# File 'lib/topolys/geometry.rb', line 342

def include?(point)
  result = ((point.x >= @minx - @tol) && (point.x <= @maxx + @tol)) &&
           ((point.y >= @miny - @tol) && (point.y <= @maxy + @tol)) &&
           ((point.z >= @minz - @tol) && (point.z <= @maxz + @tol))
  return result
end