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 <nexus/NeXusFile.hpp>
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 // Default destructor
62 virtual ~Goniometer() = default;
63 // Return rotation matrix
64 const Kernel::DblMatrix &getR() const;
65 // Set the rotation matrix
66 void setR(Kernel::DblMatrix rot);
67 // Return information about axes
68 std::string axesInfo();
69 // Add axis to goniometer
70 void pushAxis(const std::string &name, double axisx, double axisy, double axisz, double angle = 0., int sense = CCW,
71 int angUnit = angDegrees);
72 // Set rotation angle for an axis in the units the angle is set (default --
73 // degrees)
74 void setRotationAngle(const std::string &name, double value);
75 // Set rotation angle for an axis in the units the angle is set (default --
76 // degrees)
77 void setRotationAngle(size_t axisnumber, double value);
78 // Calculate goniometer for rotation around y-axis for constant wavelength
79 // from Q Sample
80 void calcFromQSampleAndWavelength(const Mantid::Kernel::V3D &Q, double wavelength, bool flip_x = false,
81 bool inner = false);
82 // Get axis object
83 const GoniometerAxis &getAxis(size_t axisnumber) const;
84 // Get axis object
85 const GoniometerAxis &getAxis(const std::string &axisname) const;
86 // Return the number of axes
87 size_t getNumberAxes() const;
88 // Make a default universal goniometer
89 void makeUniversalGoniometer();
90 // Return Euler angles acording to a convention
91 std::vector<double> getEulerAngles(const std::string &convention = "YZX");
92
93 void saveNexus(::NeXus::File *file, const std::string &group) const;
94 void loadNexus(::NeXus::File *file, const std::string &group);
96 bool isDefined() const;
97 bool operator==(const Goniometer &other) const;
98 bool operator!=(const Goniometer &other) const;
99
100private:
105 std::vector<GoniometerAxis> motors;
109 void recalculateR();
110};
111} // namespace Geometry
112} // namespace Mantid
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
bool initFromR
Flag to specify if the goniometer is initialized from a rotation matrix.
Definition: Goniometer.h:107
std::vector< GoniometerAxis > motors
Motors vector contains GoniometerAxis objects, the last one is the closest to the sample.
Definition: Goniometer.h:105
virtual ~Goniometer()=default
Kernel::DblMatrix R
Global rotation matrix of the goniometer.
Definition: Goniometer.h:102
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
double angle
GoniometerAxis direction.
Definition: Goniometer.h:41
void loadNexus(::NeXus::File *file, const std::string &group)
Definition: Goniometer.cpp:45
int angleunit
Rotation sense (1 for CCW, -1 for CW)
Definition: Goniometer.h:43
int sense
Rotation angle.
Definition: Goniometer.h:42
void saveNexus(::NeXus::File *file, const std::string &group) const
Definition: Goniometer.cpp:31
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