Skip to content

setBoundaries()

Jasmin B. Maglic edited this page Sep 12, 2020 · 1 revision
void Space::setBoundaries(const std::vector<Atom>& atoms)

This method of the Space class defines the boundaries of a box so that it contains all atoms that are contained in a vector of atoms. The boundaries are defined by two arrays containing the cartesian coordinates of the box' diagonally opposed vertices. These arrays, cart_min and cart_max are members of the Space class.

Process

For every atom in the vector atoms its cartesian coordinates are compared to the coordinates stored in cart_min and cart_max. For any dimension, whenever a coordinate is lower than or higher than the stored coordinates the box gets expanded by replacing the corresponding coordinate in cart_min or cart_max respectively. This is schematically shown in the following image.

Whenever an atom is already within the box no changes are made.

As the vector is processed, the method keeps track of and saves the largest atomic radius it has come across.

After the whole vector of atoms has been processed, the size of the box is exactly large enough to contain all atom centres. Since atoms are defined both by a position and by a radius the box needs to be larger than this, to fully contain all atoms. Hence, the box is enlarged in every direction by a number slightly larger than the largest radius found.