BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Rectangle.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Mask/Rectangle.h
6 //! @brief Defines class Rectangle.
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_DEVICE_MASK_RECTANGLE_H
16 #define BORNAGAIN_DEVICE_MASK_RECTANGLE_H
17 
18 #include "Device/Mask/IShape2D.h"
19 
20 //! A rectangle, for use in detector masks.
21 //!
22 //! Edges are along the coordinate axes.
23 //! @ingroup mask
24 
25 class Rectangle : public IShape2D {
26 public:
27  Rectangle(double xlow, double ylow, double xup, double yup);
28  Rectangle* clone() const { return new Rectangle(m_xlow, m_ylow, m_xup, m_yup); }
29 
30  bool contains(double x, double y) const;
31  bool contains(const Bin1D& binx, const Bin1D& biny) const;
32 
33  double getArea() const;
34 
35  double getXlow() const { return m_xlow; }
36  double getYlow() const { return m_ylow; }
37  double getXup() const { return m_xup; }
38  double getYup() const { return m_yup; }
39 
40 private:
41  double m_xlow, m_ylow, m_xup, m_yup;
42 };
43 
44 #endif // BORNAGAIN_DEVICE_MASK_RECTANGLE_H
Defines basic class for all 2D shapes.
Basic class for all shapes in 2D.
Definition: IShape2D.h:27
A rectangle, for use in detector masks.
Definition: Rectangle.h:25
Rectangle * clone() const
Definition: Rectangle.h:28
double m_xup
Definition: Rectangle.h:41
double m_ylow
Definition: Rectangle.h:41
Rectangle(double xlow, double ylow, double xup, double yup)
Definition: Rectangle.cpp:22
double m_xlow
Definition: Rectangle.h:41
bool contains(double x, double y) const
Returns true if point with given coordinates is inside or on border of the shape.
Definition: Rectangle.cpp:42
double getXlow() const
Definition: Rectangle.h:35
double getXup() const
Definition: Rectangle.h:37
double getArea() const
Definition: Rectangle.cpp:52
double getYlow() const
Definition: Rectangle.h:36
double getYup() const
Definition: Rectangle.h:38
double m_yup
Definition: Rectangle.h:41
Definition: Bin.h:20