BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
geometry_inc.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/ba3d/model/geometry_inc.cpp
6 //! @brief Implements geometry namespace
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include <cmath>
17 #include <functional>
18 
19 namespace RealSpace {
20 
21 // Useful constants:
22 const float GoldenRatio = (1.f + std::sqrt(5.f)) / 2.f;
23 const float IcosahedronL2R = 4.f / (10.f + 2.f * std::sqrt(5.f));
24 const float DodecahedronL2R = 4.f / std::sqrt(3.f) / (1.f + std::sqrt(5.f));
25 
26 // Keys and hash:
27 GeometricID::Key::Key(BaseShape id_, float p1_, float p2_, float p3_)
28  : id(id_), p1(p1_), p2(p2_), p3(p3_)
29 {
30 }
31 
32 bool GeometricID::Key::operator==(Key const& other) const
33 {
34  return id == other.id && p1 == other.p1 && p2 == other.p2;
35 }
36 
37 std::size_t GeometricID::KeyHash::operator()(const GeometricID::Key& key) const noexcept
38 {
39  {
40  size_t h1 = std::hash<int>{}(static_cast<int>(key.id));
41  size_t h2 = std::hash<float>{}(key.p1);
42  size_t h3 = std::hash<float>{}(key.p2);
43  size_t h4 = std::hash<float>{}(key.p3);
44  return h1 ^ (h2 ^ (h3 ^ h4));
45  }
46 }
47 } // namespace RealSpace
Defines geometry namespace.
const float DodecahedronL2R
const float GoldenRatio
const float IcosahedronL2R
std::size_t operator()(const Key &key) const noexcept
Key(BaseShape, float=0.0f, float=0.0f, float=0.0f)
bool operator==(Key const &) const