Mantid
Loading...
Searching...
No Matches
Goniometer.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include "MantidKernel/Matrix.h"
11#include "MantidKernel/V3D.h"
12#include "MantidNexus/NexusFile.h"
13#include <string>
14#include <utility>
15
16namespace Mantid {
17namespace Geometry {
18
33 CW = -1,
34 CCW = 1
35};
36
39 std::string name;
41 double angle;
42 int sense;
45 GoniometerAxis(std::string initname, const Kernel::V3D &initrotationaxis, double initangle, int initsense,
46 int initangleunit)
47 : name(std::move(initname)), rotationaxis(initrotationaxis), angle(initangle), sense(initsense),
48 angleunit(initangleunit) {}
50
51 void saveNexus(Nexus::File *file, const std::string &group) const;
52 void loadNexus(Nexus::File *file, const std::string &group);
53};
54
55class MANTID_GEOMETRY_DLL Goniometer {
56public:
57 // Default constructor
58 Goniometer();
59 // Constructor from a rotation matrix
60 Goniometer(const Kernel::DblMatrix &rot);
61 // Copy Constructor
62 Goniometer(const Goniometer &other);
63 // Copy assignment Constructor
64 Goniometer &operator=(const Goniometer &other);
65 // Move constructor
66 Goniometer(Goniometer &&other) noexcept;
67 // Move assignment Constructor
68 Goniometer &operator=(Goniometer &&other) noexcept;
69 // Default destructor
70 virtual ~Goniometer() = default;
71 // Return rotation matrix
72 const Kernel::DblMatrix &getR() const;
73 // Set the rotation matrix
74 void setR(Kernel::DblMatrix rot);
75 // Return information about axes
76 std::string axesInfo();
77 // Add axis to goniometer
78 void pushAxis(const std::string &name, double axisx, double axisy, double axisz, double angle = 0., int sense = CCW,
79 int angUnit = angDegrees);
80 // Set rotation angle for an axis in the units the angle is set (default --
81 // degrees)
82 void setRotationAngle(const std::string &name, double value);
83 // Set rotation angle for an axis in the units the angle is set (default --
84 // degrees)
85 void setRotationAngle(size_t axisnumber, double value);
86 // Calculate goniometer for rotation around y-axis for constant wavelength
87 // from Q Sample
88 void calcFromQSampleAndWavelength(const Mantid::Kernel::V3D &Q, double wavelength, bool flip_x = false,
89 bool inner = false);
90 // Get axis object
91 const GoniometerAxis &getAxis(size_t axisnumber) const;
92 // Get axis object
93 const GoniometerAxis &getAxis(const std::string &axisname) const;
94 // Return the number of axes
95 size_t getNumberAxes() const;
96 // Make a default universal goniometer
97 void makeUniversalGoniometer();
98 // Return Euler angles acording to a convention
99 std::vector<double> getEulerAngles(const std::string &convention = "YZX");
100
101 // determine the convention from the motor axes
102 std::string getConventionFromMotorAxes() const;
103
104 void saveNexus(Nexus::File *file, const std::string &group) const;
105 void loadNexus(Nexus::File *file, const std::string &group);
107 bool isDefined() const;
108 bool operator==(const Goniometer &other) const;
109 bool operator!=(const Goniometer &other) const;
110
111private:
116 std::vector<GoniometerAxis> m_motors;
120 void recalculateR();
121};
122} // namespace Geometry
123} // namespace Mantid
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
Class to represent a particular goniometer setting, which is described by the rotation matrix.
Definition Goniometer.h:55
virtual ~Goniometer()=default
bool m_initFromR
Flag to specify if the goniometer is initialized from a rotation matrix.
Definition Goniometer.h:118
std::vector< GoniometerAxis > m_motors
Motors vector contains GoniometerAxis objects, the last one is the closest to the sample.
Definition Goniometer.h:116
Kernel::DblMatrix m_R
Global rotation matrix of the goniometer.
Definition Goniometer.h:113
Class for 3D vectors.
Definition V3D.h:34
@ CCW
Clockwise rotation.
Definition Goniometer.h:34
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
Counter clockwise rotation.
Definition Goniometer.h:38
void loadNexus(Nexus::File *file, const std::string &group)
double angle
GoniometerAxis direction.
Definition Goniometer.h:41
int angleunit
Rotation sense (1 for CCW, -1 for CW)
Definition Goniometer.h:43
Kernel::V3D rotationaxis
GoniometerAxis name.
Definition Goniometer.h:40
GoniometerAxis(std::string initname, const Kernel::V3D &initrotationaxis, double initangle, int initsense, int initangleunit)
angle units are angDegrees or angRadians (see AngleUnits.h)
Definition Goniometer.h:45
void saveNexus(Nexus::File *file, const std::string &group) const