38 glm::vec4
colour = glm::vec4(1.0, 0.5, 0.5, 1.0),
40 glm::vec3
force = glm::vec3(0)
64 glm::vec4
colour = glm::vec4(1.0, 0.5, 0.5, 1.0),
66 glm::vec3
force = glm::vec3(0)
108 glm::vec3 com = glm::vec3(0);
109 for (
const auto & atom : atoms)
111 com += atom.position;
113 return com / float(atoms.size());
124 for (
auto & atom : atoms)
126 atom.position -= com;
136void centerOn(std::vector<Atom> & atoms, uint64_t index)
139 glm::vec3 pos = atoms[index].position;
140 for (
auto & atom : atoms)
142 atom.position -= pos;
148 for (
auto & atom : atoms) { atom.position += r; }
157glm::vec3
min(
const std::vector<Atom> & atoms)
159 glm::vec3
min = glm::vec3(std::numeric_limits<float>::max());
160 for (
const auto & atom : atoms)
162 for (uint8_t i = 0; i < 3; i++)
164 min[i] = std::min(
min[i], atom.position[i]);
176glm::vec3
max(
const std::vector<Atom> & atoms)
178 glm::vec3
max = glm::vec3(-std::numeric_limits<float>::max());
179 for (
const auto & atom : atoms)
181 for (uint8_t i = 0; i < 3; i++)
183 max[i] = std::max(
max[i], atom.position[i]);
195glm::vec3
extent(
const std::vector<Atom> & atoms)
197 glm::vec3
min = glm::vec3(std::numeric_limits<float>::max());
198 glm::vec3
max = glm::vec3(-std::numeric_limits<float>::max());
199 for (
const auto & atom : atoms)
201 for (uint8_t i = 0; i < 3; i++)
203 min[i] = std::min(
min[i], atom.position[i]);
204 max[i] = std::max(
max[i], atom.position[i]);
219 for (
const auto & atom : atoms)
221 e.insert(atom.symbol);
234 float r = -std::numeric_limits<float>::max();
235 for (
const auto & atom : atoms)
237 r = std::max(r, atom.scale);
250 std::multimap<Element, uint64_t> m;
251 for (uint64_t i = 0; i < atoms.size(); i++)
253 m.insert(std::pair(atoms[i].symbol, i));
266 std::vector<Atom> & atoms,
267 const std::map<uint64_t, glm::vec4> & colours
270 for (
const auto & ic : colours)
272 atoms[ic.first].colour = ic.second;
284 std::vector<Atom> & atoms,
285 const std::vector<float> sizes
288 for (uint64_t i = 0; i < sizes.size(); i++)
290 atoms[i].scale = sizes[i];
void applySizes(std::vector< Atom > &atoms, const std::vector< float > sizes)
Apply sizes by index.
Definition atom.h:283
void center(std::vector< Atom > &atoms)
Subtract the centre of mass of some Atoms.
Definition atom.h:121
glm::vec3 getCenter(const std::vector< Atom > &atoms)
Calculate the centre of mass.
Definition atom.h:106
void centerOn(std::vector< Atom > &atoms, uint64_t index)
Centre on a particular Atom.
Definition atom.h:136
void applyColours(std::vector< Atom > &atoms, const std::map< uint64_t, glm::vec4 > &colours)
Apply colours by index.
Definition atom.h:265
std::multimap< Element, uint64_t > elementIndices(const std::vector< Atom > &atoms)
Obtain indices of each element.
Definition atom.h:248
std::set< Element > uniqueElements(const std::vector< Atom > &atoms)
Determine the unique elements in a list of Atom.
Definition atom.h:216
glm::vec3 max(const std::vector< Atom > &atoms)
Calculate the maximum positions of some Atoms.
Definition atom.h:176
glm::vec3 extent(const std::vector< Atom > &atoms)
Calculate the extent of some Atoms.
Definition atom.h:195
glm::vec3 min(const std::vector< Atom > &atoms)
Calculate the minimum positions of some Atoms.
Definition atom.h:157
float largest(const std::vector< Atom > &atoms)
Calculate the largest Atom.
Definition atom.h:232
void translate(std::vector< Atom > &atoms, glm::vec3 r)
Definition atom.h:146
std::ostream & operator<<(std::ostream &o, Atom &atom)
Print an atom to std::ostream.
Definition atom.h:95
An atom structure.
Definition atom.h:20
glm::vec3 force
Definition atom.h:82
Element symbol
Definition atom.h:77
glm::vec3 position
Definition atom.h:78
float scale
Definition atom.h:79
glm::vec3 velocity
Definition atom.h:81
Atom(glm::vec3 position=glm::vec3(0), float scale=1.0f, glm::vec4 colour=glm::vec4(1.0, 0.5, 0.5, 1.0), glm::vec3 velocity=glm::vec3(0), glm::vec3 force=glm::vec3(0))
Construct a Atom of unknown Element type.
Definition atom.h:61
Atom(Element symbol, glm::vec3 position=glm::vec3(0), float scale=1.0f, glm::vec4 colour=glm::vec4(1.0, 0.5, 0.5, 1.0), glm::vec3 velocity=glm::vec3(0), glm::vec3 force=glm::vec3(0))
Construct a Atom of a given Element.
Definition atom.h:34
glm::vec4 colour
Definition atom.h:80
Element
Representable elements.
Definition element.h:13