BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Bin.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Axis/Bin.h
6 //! @brief Defines structs Bin1D, Bin1DCVector
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 
15 #ifndef BORNAGAIN_BASE_AXIS_BIN_H
16 #define BORNAGAIN_BASE_AXIS_BIN_H
17 
18 #include "Base/Vector/Vectors3D.h"
19 
20 struct Bin1D {
21  Bin1D() : m_lower(0), m_upper(0) {}
22  Bin1D(double lower, double upper) : m_lower(lower), m_upper(upper) {}
23  double m_lower; //!< lower bound of the bin
24  double m_upper; //!< upper bound of the bin
25  double center() const { return (m_lower + m_upper) / 2.0; }
26  double binSize() const { return m_upper - m_lower; }
27 };
28 
29 //! Checks if value is contained in bin:
30 //! value in [m_lower, m_upper)
31 bool BinContains(const Bin1D& bin, double value);
32 
33 //! An one-dimensional range of kvector_t's.
34 //! @ingroup tools_internal
35 
36 struct Bin1DKVector {
38  Bin1DKVector(const kvector_t lower, const kvector_t upper) : m_q_lower(lower), m_q_upper(upper)
39  {
40  }
41  Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin);
42 
43  kvector_t center() const { return (m_q_lower + m_q_upper) / 2.0; }
44  kvector_t span() const { return m_q_upper - m_q_lower; }
45  kvector_t m_q_lower; //!< lower bound of the bin
46  kvector_t m_q_upper; //!< upper bound of the bin
47 };
48 
49 //! An one-dimensional range of cvector_t's.
50 //! @ingroup tools_internal
51 
52 class Bin1DCVector {
53 public:
55  Bin1DCVector(cvector_t lower, cvector_t upper) : m_q_lower(lower), m_q_upper(upper) {}
56  Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin);
57  cvector_t center() const { return (m_q_lower + m_q_upper) / 2.0; }
58  cvector_t span() const { return m_q_upper - m_q_lower; }
59  cvector_t m_q_lower; //!< lower bound of the bin
60  cvector_t m_q_upper; //!< upper bound of the bin
61 };
62 
63 #endif // BORNAGAIN_BASE_AXIS_BIN_H
bool BinContains(const Bin1D &bin, double value)
Checks if value is contained in bin: value in [m_lower, m_upper)
Definition: Bin.cpp:18
Defines basic vectors in Z^3, R^3, C^3.
An one-dimensional range of cvector_t's.
Definition: Bin.h:52
cvector_t span() const
Definition: Bin.h:58
cvector_t m_q_lower
lower bound of the bin
Definition: Bin.h:59
cvector_t m_q_upper
upper bound of the bin
Definition: Bin.h:60
Bin1DCVector()
Definition: Bin.h:54
Bin1DCVector(cvector_t lower, cvector_t upper)
Definition: Bin.h:55
cvector_t center() const
Definition: Bin.h:57
An one-dimensional range of kvector_t's.
Definition: Bin.h:36
Bin1DKVector(const kvector_t lower, const kvector_t upper)
Definition: Bin.h:38
kvector_t m_q_lower
lower bound of the bin
Definition: Bin.h:45
kvector_t span() const
Definition: Bin.h:44
Bin1DKVector()
Definition: Bin.h:37
kvector_t m_q_upper
upper bound of the bin
Definition: Bin.h:46
kvector_t center() const
Definition: Bin.h:43
Definition: Bin.h:20
double center() const
Definition: Bin.h:25
double binSize() const
Definition: Bin.h:26
Bin1D(double lower, double upper)
Definition: Bin.h:22
double m_upper
upper bound of the bin
Definition: Bin.h:24
double m_lower
lower bound of the bin
Definition: Bin.h:23
Bin1D()
Definition: Bin.h:21