struct Chem::Spatial::CoordinatesProxy

Included Modules

Defined in:

chem/spatial/coordinates_proxy.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(atoms : AtomCollection, lattice : Lattice | Nil = nil) #

[View source]

Instance Method Detail

def ==(rhs : Enumerable(Vector)) : Bool #

[View source]
def bounds : Bounds #

[View source]
def center : Vector #

[View source]
def center_along(vec : Vector) : self #

Translates coordinates so that the center is at the middle of vec.

structure = Structure.read "path/to/file"
structure.coords.center # => [1.5 2.0 3.2]
structure.coords.center_along Vector[0, 10, 0]
structure.coords.center # => [1.5 5.0 3.2]

[View source]
def center_at(vec : Vector) : self #

Translates coordinates so that the center is at vec.

structure = Structure.read "path/to/file"
structure.coords.center # => [1.0 2.0 3.0]
structure.coords.center_at Vector[10, 20, 30]
structure.coords.center # => [10 20 30]

[View source]
def center_at_cell : self #

Translates coordinates so that they are centered at the primary unit cell.

Raises NotPeriodicError if coordinates are not periodic.

structure = Structure.read "path/to/file"
structure.lattice       # => [[1.0 0.0 0.0] [0.0 25.0 0.0] [0.0 0.0 213]]
structure.coords.center # => [1.0 2.0 3.0]
structure.coords.center_at_cell
structure.coords.center # => [0.5 12.5 106.5]

structure = Structure.read "path/to/non_periodic_file"
structure.coords.center_at_cell # raises NotPeriodicError

[View source]
def center_at_origin : self #

Translates coordinates so that the center is at the origin.

structure = Structure.read "path/to/file"
structure.coords.center # => [1.0 2.0 3.0]
structure.coords.center_at_origin
structure.coords.center # => [0.0 0.0 0.0]

[View source]
def com : Vector #

Returns the center of mass.

structure = Chem::Structure.build do
  atom :O, Vector[1, 2, 3]
  atom :H, Vector[4, 5, 6]
  atom :H, Vector[7, 8, 9]
end
structure.coords.center # => [4.0 5.0 6.0]
structure.coords.com    # => [1.5035248 2.5035248 3.5035248]

[View source]
def each(fractional : Bool = false) : Iterator(Vector) #
Description copied from module Iterable(Chem::Spatial::Vector)

Must return an Iterator over the elements in this collection.


[View source]
def each(fractional : Bool = false, &block : Vector -> ) #
Description copied from module Enumerable(Chem::Spatial::Vector)

Must yield this collection's elements to the block.


[View source]
def each_with_atom(fractional : Bool = false, &block : Vector, Atom -> ) #

[View source]
def map(fractional : Bool = false, &block : Vector -> Vector) : Array(Vector) #
Description copied from module Enumerable(Chem::Spatial::Vector)

Returns an Array with the results of running the block against each element of the collection.

[1, 2, 3].map { |i| i * 10 } # => [10, 20, 30]

[View source]
def map!(fractional : Bool = false, &block : Vector -> Vector) : self #

[View source]
def map_with_atom(fractional : Bool = false, &block : Vector, Atom -> Vector) : Array(Vector) #

[View source]
def map_with_atom!(fractional : Bool = false, &block : Vector, Atom -> Vector) : self #

[View source]
def to_a(fractional : Bool = false) : Array(Vector) #
Description copied from module Enumerable(Chem::Spatial::Vector)

Returns an Array with all the elements in the collection.

(1..5).to_a # => [1, 2, 3, 4, 5]

[View source]
def to_cartesian! : self #

[View source]
def to_fractional! : self #

[View source]
def transform(transform : AffineTransform) : Array(Vector) #

[View source]
def transform!(transform : AffineTransform) : self #

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

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

[View source]
def wrap(around center : Vector | Nil = nil) : self #

[View source]
def wrap(lattice : Lattice, around center : Vector | Nil = nil) : self #

[View source]