Mantid
Loading...
Searching...
No Matches
ResizeRectangularDetectorHelper.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
11
12namespace Mantid::API {
13
15 Geometry::ComponentID componentId, const double scaleX,
16 const double scaleY) {
17
18 const size_t componentIndex = componentInfo.indexOf(componentId);
19 // Precompute transformation: Undo translation, undo rotation, scale, rotate
20 // back, translate back:
21 Eigen::Affine3d transformation(Eigen::Scaling(Eigen::Vector3d(scaleX, scaleY, 1)));
22 const auto rotation = toQuaterniond(componentInfo.rotation(componentIndex));
23 transformation.rotate(rotation.conjugate());
24 transformation.prerotate(rotation);
25 const auto origin = Kernel::toVector3d(componentInfo.position(componentIndex));
26 transformation.translate(-origin);
27 transformation.pretranslate(origin);
28
29 for (auto index : componentInfo.detectorsInSubtree(componentIndex)) {
30 auto newPos = Kernel::toV3D(transformation * Kernel::toVector3d(componentInfo.position(index)));
31 componentInfo.setPosition(index, newPos);
32 }
33}
34
35} // namespace Mantid::API
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
ComponentInfo : Provides a component centric view on to the instrument.
Definition: ComponentInfo.h:40
Kernel::Quat rotation(const size_t componentIndex) const
Kernel::V3D position(const size_t componentIndex) const
size_t indexOf(Geometry::IComponent *id) const
std::vector< size_t > detectorsInSubtree(size_t componentIndex) const
void setPosition(size_t componentIndex, const Kernel::V3D &newPosition)
base class for Geometric IComponent
Definition: IComponent.h:51
void conjugate()
Take the complex conjugate.
Definition: Quat.cpp:357
MANTID_API_DLL void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, Geometry::IComponent *componentId, const double scaleX, const double scaleY)
Helpers for resizing RectangularDetectors.
Eigen::Vector3d toVector3d(const Kernel::V3D &vec)
Converts Kernel::V3D to Eigen::Vector3d.
Kernel::V3D toV3D(const Eigen::Vector3d &vec)
This header provides conversion helpers between vector and rotation types in MantidKernel and equival...
Eigen::Quaterniond toQuaterniond(const Kernel::Quat &quat)
Converts Kernel::Quat to Eigen::Quaterniond.