struct Chem::Spatial::Bounds

Defined in:

chem/spatial/bounds.cr

Constructors

Instance Method Summary

Constructor Detail

def self.[](a : Float64, b : Float64, c : Float64) : self #

[View source]
def self.new(origin : Vector, basis : Basis) #

[View source]
def self.new(vmin : Vector, vmax : Vector) : self #

[View source]
def self.new(origin : Vector, *args, **options) : self #

[View source]
def self.new(*args, **options) : self #

[View source]
def self.zero : self #

[View source]

Instance Method Detail

def +(rhs : Vector) : self #

[View source]
def -(rhs : Vector) : self #

[View source]
def a(*args, **options) #

[View source]
def a(*args, **options, &) #

[View source]
def alpha(*args, **options) #

[View source]
def alpha(*args, **options, &) #

[View source]
def angles(*args, **options) #

[View source]
def angles(*args, **options, &) #

[View source]
def b(*args, **options) #

[View source]
def b(*args, **options, &) #

[View source]
def basis : Basis #

[View source]
def beta(*args, **options) #

[View source]
def beta(*args, **options, &) #

[View source]
def c(*args, **options) #

[View source]
def c(*args, **options, &) #

[View source]
def center : Vector #

[View source]
def each_vertex(& : Vector -> ) : Nil #

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]

[View source]
def gamma(*args, **options) #

[View source]
def gamma(*args, **options, &) #

[View source]
def i(*args, **options) #

[View source]
def i(*args, **options, &) #

[View source]
def includes?(bounds : Bounds) : Bool #

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

[View source]
def includes?(vec : Vector) : Bool #

[View source]
def j(*args, **options) #

[View source]
def j(*args, **options, &) #

[View source]
def k(*args, **options) #

[View source]
def k(*args, **options, &) #

[View source]
def max : Vector #

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]

[View source]
def min : Vector #

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]

[View source]
def origin : Vector #

[View source]
def pad(padding : Number) : self #

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]

[View source]
def size(*args, **options) #

[View source]
def size(*args, **options, &) #

[View source]
def translate(offset : Vector) : self #

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]

[View source]
def vertices : Array(Vector) #

Returns bounds' vertices.

bounds = Bounds[5, 10, 20]
bounds.vertices # => [Vector[0.0, 0.0, 0.0], Vector[0.0, 0.0, 20.0], ...]

[View source]
def volume : Float64 #

[View source]