23using namespace Geometry;
34 "The name of the workspace for which the new instrument "
35 "configuration will have an effect. Any other workspaces "
36 "stored in the analysis data service will be unaffected.");
38 "The angle of rotation in degrees (according "
39 "to the handedness of the coordinate system.");
56 inst = inputW->getInstrument();
58 throw std::runtime_error(
"Could not get a valid instrument from the "
59 "MatrixWorkspace provided as input");
61 inst = inputP->getInstrument();
63 throw std::runtime_error(
"Could not get a valid instrument from the "
64 "PeaksWorkspace provided as input");
66 throw std::runtime_error(
"Input workspaces does not seem to be valid (must "
67 "be either MatrixWorkspace or PeaksWorkspace)");
75 auto refFrame = inst->getReferenceFrame();
77 throw std::runtime_error(
"Could not get a valid reference frame");
81 auto beam = refFrame->vecPointingAlongBeam();
82 auto up = refFrame->vecPointingUp();
83 auto rotationAxis = up.cross_prod(beam);
86 auto handedness = refFrame->getHandedness();
87 if (handedness ==
Left) {
92 auto source = inst->getSource();
94 throw std::runtime_error(
"Could not get the source's position");
97 auto sample = inst->getSample();
99 throw std::runtime_error(
"Could not get the sample's position");
101 auto samplePos = sample->getPos();
103 auto sourcePos = source->getPos() - samplePos;
106 Quat quat(angle, rotationAxis);
108 sourcePos += samplePos;
111 std::string sourceName = source->getName();
116 move->setProperty(
"Workspace", ws);
117 move->setProperty(
"ComponentName", sourceName);
118 move->setProperty(
"X", sourcePos.X());
119 move->setProperty(
"Y", sourcePos.Y());
120 move->setProperty(
"Z", sourcePos.Z());
121 move->setProperty(
"RelativePosition",
false);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
A property class for workspaces.
void init() override
Initialize the algorithm's properties.
void exec() override
Execute the algorithm.
void rotate(V3D &) const
Rotate a vector.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
Describes the direction (within an algorithm) of a Property.
@ InOut
Both an input & output workspace.