BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Bin.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Axis/Bin.cpp
6 //! @brief Implements 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 #include "Base/Axis/Bin.h"
16 #include "Base/Vector/Direction.h"
17 
18 bool BinContains(const Bin1D& bin, double value)
19 {
20  if (bin.binSize() == 0.0)
21  return false;
22  double coordinate = (value - bin.m_lower) / bin.binSize();
23  if (coordinate < 0.0)
24  return false;
25  if (coordinate >= 1.0)
26  return false;
27  return true;
28 }
29 
30 //! creation on Bin1DKVector from alpha and phi bins
31 Bin1DKVector::Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin)
32  : m_q_lower(), m_q_upper()
33 {
34  m_q_lower = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower);
35  m_q_upper = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper);
36 }
37 
38 //! creation on Bin1DCVector from alpha and phi bins
39 Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin)
40  : m_q_lower(), m_q_upper()
41 {
42  m_q_lower = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower).complex();
43  m_q_upper = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper).complex();
44 }
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 structs Bin1D, Bin1DCVector.
kvector_t vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Definition: Direction.cpp:19
Defines class Direction.
BasicVector3D< complex_t > complex() const
Returns this, trivially converted to complex type.
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
kvector_t m_q_lower
lower bound of the bin
Definition: Bin.h:45
Bin1DKVector()
Definition: Bin.h:37
kvector_t m_q_upper
upper bound of the bin
Definition: Bin.h:46
Definition: Bin.h:20
double binSize() const
Definition: Bin.h:26
double m_upper
upper bound of the bin
Definition: Bin.h:24
double m_lower
lower bound of the bin
Definition: Bin.h:23