BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IAxis.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Axis/IAxis.cpp
6 //! @brief Implements interface IAxis.
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/IAxis.h"
16 
17 bool IAxis::equals(const IAxis& other) const
18 {
19  return getName() == other.getName();
20 }
21 
22 std::vector<double> IAxis::binCenters() const
23 {
24  throw std::runtime_error("IAxis::binCenters() -> Error. Not implemented.");
25 }
26 
27 std::vector<double> IAxis::binBoundaries() const
28 {
29  throw std::runtime_error("IAxis::binBoundaries() -> Error. Not implemented.");
30 }
31 
32 IAxis* IAxis::createClippedAxis(double /* left */, double /* right */) const
33 {
34  throw std::runtime_error("IAxis::createClippedAxis() -> Error. Not implemented.");
35 }
36 
37 bool IAxis::contains(double value) const
38 {
39  return value >= lowerBound() && value < upperBound();
40 }
41 
42 double IAxis::span() const
43 {
44  return upperBound() - lowerBound();
45 }
46 
47 double IAxis::center() const
48 {
49  return (upperBound() + lowerBound()) / 2;
50 }
Defines interface IAxis.
Interface for one-dimensional axes.
Definition: IAxis.h:25
virtual IAxis * createClippedAxis(double left, double right) const
Creates a new clipped axis.
Definition: IAxis.cpp:32
double span() const
Returns distance from first to last point.
Definition: IAxis.cpp:42
virtual bool contains(double value) const
Returns true if axis contains given point.
Definition: IAxis.cpp:37
virtual std::vector< double > binCenters() const
Definition: IAxis.cpp:22
virtual std::vector< double > binBoundaries() const
Definition: IAxis.cpp:27
virtual bool equals(const IAxis &other) const
Definition: IAxis.cpp:17
virtual double upperBound() const =0
Returns value of last point of axis.
virtual double lowerBound() const =0
Returns value of first point of axis.
std::string getName() const
retrieve the label of the axis
Definition: IAxis.h:40
double center() const
Returns midpoint of axis.
Definition: IAxis.cpp:47