BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
def.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/ba3d/def.h
6 //! @brief Definitions in namespace GUI::RealSpace
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_GUI_BA3D_DEF_H
16 #define BORNAGAIN_GUI_BA3D_DEF_H
17 
18 #if defined(__GNUC__) && !defined(__APPLE__)
19 #pragma GCC diagnostic ignored "-Wswitch-enum"
20 #pragma GCC diagnostic ignored "-Wpadded"
21 #pragma GCC diagnostic ignored "-Wfloat-equal"
22 #endif
23 
24 #include <QVector3D>
25 
26 namespace GUI::RealSpace {
27 
28 // coordinates
29 struct Vector3D {
30  float x, y, z;
31 
32  Vector3D();
33  Vector3D(float);
34  Vector3D(float, float, float);
35 
36  Vector3D(const Vector3D&) = default;
37 
38  Vector3D(QVector3D const&);
39  operator QVector3D() const;
40 
41  float length() const;
42  Vector3D normalized() const;
43 
44  Vector3D interpolateTo(const Vector3D&, float) const;
45 
46  static Vector3D const _0, _1, _x, _y, _z;
47 };
48 
49 // products
50 Vector3D cross(const Vector3D&, const Vector3D&);
51 float dot(const Vector3D&, const Vector3D&);
52 
55 Vector3D operator*(const Vector3D&, float);
56 
57 Vector3D operator+(const Vector3D&, const Vector3D&);
58 Vector3D operator-(const Vector3D&, const Vector3D&);
59 
60 //! Range of float
61 struct Range {
62  float min, max;
63  Range(float, float);
64 
65  float size() const;
66  float mid() const;
67 };
68 
69 //! Range of coordinates
70 struct VectorRange {
71  Range x, y, z;
74 
75  Vector3D size() const;
76  Vector3D mid() const;
77 
78  float length() const;
79 };
80 
81 } // namespace GUI::RealSpace
82 
83 #endif // BORNAGAIN_GUI_BA3D_DEF_H
Vector3D operator*(const Vector3D &v, float f)
Definition: def.cpp:87
Vector3D cross(const Vector3D &v1, const Vector3D &v2)
Definition: def.cpp:67
Vector3D operator-(const Vector3D &v)
Definition: def.cpp:82
Vector3D operator+(const Vector3D &v)
Definition: def.cpp:77
float dot(const Vector3D &v1, const Vector3D &v2)
Definition: def.cpp:72
Range of float.
Definition: def.h:61
float mid() const
Definition: def.cpp:114
float size() const
Definition: def.cpp:109
Range(float, float)
Definition: def.cpp:103
static Vector3D const _y
Definition: def.h:46
static Vector3D const _x
Definition: def.h:46
Vector3D(const Vector3D &)=default
static Vector3D const _z
Definition: def.h:46
static Vector3D const _0
Definition: def.h:46
Vector3D normalized() const
Definition: def.cpp:49
Vector3D interpolateTo(const Vector3D &, float) const
Definition: def.cpp:54
static Vector3D const _1
Definition: def.h:46
float length() const
Definition: def.cpp:44
Range of coordinates.
Definition: def.h:70
VectorRange(Range, Range, Range)
Definition: def.cpp:120
float length() const
Definition: def.cpp:144
Vector3D mid() const
Definition: def.cpp:139
Vector3D size() const
Definition: def.cpp:134