Class: Topolys::BoundingBox
- Inherits:
-
Object
- Object
- Topolys::BoundingBox
- Defined in:
- lib/topolys/geometry.rb
Overview
Plane3D
Instance Attribute Summary collapse
-
#maxx ⇒ Object
readonly
Returns the value of attribute maxx.
-
#maxy ⇒ Object
readonly
Returns the value of attribute maxy.
-
#maxz ⇒ Object
readonly
Returns the value of attribute maxz.
-
#minx ⇒ Object
readonly
Returns the value of attribute minx.
-
#miny ⇒ Object
readonly
Returns the value of attribute miny.
-
#minz ⇒ Object
readonly
Returns the value of attribute minz.
Instance Method Summary collapse
- #add_point(point) ⇒ Object
- #include?(point) ⇒ Boolean
-
#initialize(tol = 0.001) ⇒ BoundingBox
constructor
A new instance of BoundingBox.
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
#maxx ⇒ Object (readonly)
Returns the value of attribute maxx.
321 322 323 |
# File 'lib/topolys/geometry.rb', line 321 def maxx @maxx end |
#maxy ⇒ Object (readonly)
Returns the value of attribute maxy.
321 322 323 |
# File 'lib/topolys/geometry.rb', line 321 def maxy @maxy end |
#maxz ⇒ Object (readonly)
Returns the value of attribute maxz.
321 322 323 |
# File 'lib/topolys/geometry.rb', line 321 def maxz @maxz end |
#minx ⇒ Object (readonly)
Returns the value of attribute minx.
321 322 323 |
# File 'lib/topolys/geometry.rb', line 321 def minx @minx end |
#miny ⇒ Object (readonly)
Returns the value of attribute miny.
321 322 323 |
# File 'lib/topolys/geometry.rb', line 321 def miny @miny end |
#minz ⇒ Object (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
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 |