BornAgain  1.18.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 scattering at grazing incidence
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_CORE_AXIS_BIN_H
16 #define BORNAGAIN_CORE_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 getMidPoint() const { return (m_lower + m_upper) / 2.0; }
26  double getBinSize() 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 getMidPoint() const { return (m_q_lower + m_q_upper) / 2.0; }
44  kvector_t getDelta() 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 
53 {
54 public:
56  Bin1DCVector(cvector_t lower, cvector_t upper) : m_q_lower(lower), m_q_upper(upper) {}
57  Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin);
58  cvector_t getMidPoint() const { return (m_q_lower + m_q_upper) / 2.0; }
59  cvector_t getDelta() const { return m_q_upper - m_q_lower; }
60  cvector_t m_q_lower; //!< lower bound of the bin
61  cvector_t m_q_upper; //!< upper bound of the bin
62 };
63 
64 #endif // BORNAGAIN_CORE_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:17
Defines basic vectors in R^3 and C^3.
An one-dimensional range of cvector_t's.
Definition: Bin.h:53
cvector_t m_q_lower
lower bound of the bin
Definition: Bin.h:60
cvector_t m_q_upper
upper bound of the bin
Definition: Bin.h:61
Bin1DCVector()
Definition: Bin.h:55
cvector_t getDelta() const
Definition: Bin.h:59
Bin1DCVector(cvector_t lower, cvector_t upper)
Definition: Bin.h:56
cvector_t getMidPoint() const
Definition: Bin.h:58
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 getMidPoint() const
Definition: Bin.h:43
Bin1DKVector()
Definition: Bin.h:37
kvector_t m_q_upper
upper bound of the bin
Definition: Bin.h:46
kvector_t getDelta() const
Definition: Bin.h:44
Definition: Bin.h:20
Bin1D(double lower, double upper)
Definition: Bin.h:22
double m_upper
upper bound of the bin
Definition: Bin.h:24
double getBinSize() const
Definition: Bin.h:26
double m_lower
lower bound of the bin
Definition: Bin.h:23
Bin1D()
Definition: Bin.h:21
double getMidPoint() const
Definition: Bin.h:25