struct Chem::Spatial::Bounds
- Chem::Spatial::Bounds
- Struct
- Value
- Object
Defined in:
chem/spatial/bounds.crConstructors
- .[](a : Float64, b : Float64, c : Float64) : self
- .new(origin : Vector, basis : Basis)
- .new(vmin : Vector, vmax : Vector) : self
- .new(origin : Vector, *args, **options) : self
- .new(*args, **options) : self
- .zero : self
Instance Method Summary
- #+(rhs : Vector) : self
- #-(rhs : Vector) : self
- #a(*args, **options)
- #a(*args, **options, &)
- #alpha(*args, **options)
- #alpha(*args, **options, &)
- #angles(*args, **options)
- #angles(*args, **options, &)
- #b(*args, **options)
- #b(*args, **options, &)
- #basis : Basis
- #beta(*args, **options)
- #beta(*args, **options, &)
- #c(*args, **options)
- #c(*args, **options, &)
- #center : Vector
-
#each_vertex(& : Vector -> ) : Nil
Yields bounds' vertices.
- #gamma(*args, **options)
- #gamma(*args, **options, &)
- #i(*args, **options)
- #i(*args, **options, &)
-
#includes?(bounds : Bounds) : Bool
Returns
true
if the current instance contains bounds,false
otherwise. - #includes?(vec : Vector) : Bool
- #j(*args, **options)
- #j(*args, **options, &)
- #k(*args, **options)
- #k(*args, **options, &)
-
#max : Vector
Returns maximum edge.
-
#min : Vector
Returns minimum edge.
- #origin : Vector
-
#pad(padding : Number) : self
Returns a bounds with its extents expanded by padding in every direction.
- #size(*args, **options)
- #size(*args, **options, &)
-
#translate(offset : Vector) : self
Returns a bounds translated by offset.
-
#vertices : Array(Vector)
Returns bounds' vertices.
- #volume : Float64
Constructor Detail
Instance Method Detail
Yields bounds' vertices.
Bounds[5, 10, 20].each_vertex { |vec| puts vec }
Prints:
Vector[0.0, 0.0, 0.0]
Vector[0.0, 0.0, 20.0]
Vector[0.0, 10.0, 0.0]
Vector[0.0, 10.0, 20.0]
Vector[5.0, 0.0, 0.0]
Vector[5.0, 0.0, 20.0]
Vector[5.0, 10.0, 0.0]
Vector[5.0, 10.0, 20.0]
Returns true
if the current instance contains bounds, false
otherwise.
It effectively checks if every vertex of bounds is contained by the current instance.
bounds = Bounds.new S[10, 10, 10], 90, 90, 120
bounds.includes? Bounds.new(Size[5, 4, 6]) # => true
bounds.includes? Bounds.new(Vector[-1, 2, -4], Size[5, 4, 6])) # => false
Returns maximum edge.
bounds = Bounds.new V[1.5, 3, -0.4], S[10, 10, 12], 90, 90, 120
bounds.max # => Vector[6.5, 11.66, 11.6]
Returns minimum edge. This is equivalent to the origin.
bounds = Bounds.new V[1.5, 3, -0.4], S[10, 10, 12], 90, 90, 120
bounds.min # => Vector[1.5, 3, -0.4]
Returns a bounds with its extents expanded by padding in every
direction. Note that its size is actually increased by padding * 2
.
bounds = Bounds.new Vector[1, 5, 3], S[10, 5, 12]
bounds.center # => Vector[6.0, 7.5, 9.0]
bounds = bounds.pad(2.5)
bounds.size # => Size[15, 10, 17]
bounds.center # => Vector[6.0, 7.5, 9.0]
Returns a bounds translated by offset.
bounds = Bounds.new V[-5, 1, 20], S[10, 10, 10], 90, 90, 120
bounds.translate(V[1, 2, 10]).min # => Vector[-4.0, 3.0, 30.0]
Returns bounds' vertices.
bounds = Bounds[5, 10, 20]
bounds.vertices # => [Vector[0.0, 0.0, 0.0], Vector[0.0, 0.0, 20.0], ...]