Newer
Older
// ************************************************************************** //

Wuttke, Joachim
committed
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file Tools/inc/Bin.h

Wuttke, Joachim
committed
//! @brief Defines structs Bin1D, Bin1DCVector
//!
//! @homepage http://apps.jcns.fz-juelich.de/BornAgain

Wuttke, Joachim
committed
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2013
//! @authors Scientific Computing Group at MLZ Garching
//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
Van Herck, Walter
committed
#ifndef BIN_H_
#define BIN_H_
#include "Numeric.h"
Van Herck, Walter
committed
//! @class Bin1D
//! @ingroup tools_internal
//! @brief One dimensional bin with left and right bounds.
Van Herck, Walter
committed
struct Bin1D
{
double m_lower; //!< lower bound of the bin
double m_upper; //!< upper bound of the bin
double getMidPoint() const { return (m_lower + m_upper)/2.0; }
};
//! @class Bin1DCVector
//! @ingroup tools_internal
//! @brief An one-dimensional range of cvector_t's
Van Herck, Walter
committed
struct Bin1DCVector
{
Van Herck, Walter
committed
: m_q_lower(lower), m_q_upper(upper) {}
Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin);
Van Herck, Walter
committed
cvector_t getMidPoint() const { return (m_q_lower + m_q_upper)/2.0; }
Van Herck, Walter
committed
cvector_t getDelta() const { return m_q_upper - m_q_lower; }
cvector_t m_q_lower; //!< lower bound of the bin
cvector_t m_q_upper; //!< upper bound of the bin
Van Herck, Walter
committed
};
Van Herck, Walter
committed
{
if (std::abs(left.m_lower - right.m_lower) > Numeric::double_epsilon) return false;
if (std::abs(left.m_upper - right.m_upper) > Numeric::double_epsilon) return false;
return true;
}
Van Herck, Walter
committed
return !(left==right);
}
//! creation on Bin1DCVector from alpha and phi bins
inline Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin) : m_q_lower(), m_q_upper()
{
m_q_lower.setLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower);
m_q_upper.setLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper);
}
Van Herck, Walter
committed
#endif /* BIN_H_ */