BornAgain  1.18.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 scattering at grazing incidence
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 
17 bool BinContains(const Bin1D& bin, double value)
18 {
19  if (bin.getBinSize() == 0.0)
20  return false;
21  double coordinate = (value - bin.m_lower) / bin.getBinSize();
22  if (coordinate < 0.0)
23  return false;
24  if (coordinate >= 1.0)
25  return false;
26  return true;
27 }
28 
29 //! creation on Bin1DKVector from alpha and phi bins
30 Bin1DKVector::Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin)
31  : m_q_lower(), m_q_upper()
32 {
35 }
36 
37 //! creation on Bin1DCVector from alpha and phi bins
38 Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin)
39  : m_q_lower(), m_q_upper()
40 {
43 }
BasicVector3D< double > vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Creates a vector<double> as a wavevector with given wavelength and angles.
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 structs Bin1D, Bin1DCVector.
BasicVector3D< std::complex< double > > complex() const
Returns this, trivially converted to complex type.
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
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 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