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 +
10
11namespace Mantid::API {
12
13void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, const size_t componentIndex,
14 const double scaleX, const double scaleY) {
15 // Precompute transformation: Undo translation, undo rotation, scale, rotate
16 // back, translate back:
17 Eigen::Affine3d transformation(Eigen::Scaling(Eigen::Vector3d(scaleX, scaleY, 1)));
18 const auto rotation = toQuaterniond(componentInfo.rotation(componentIndex));
19 transformation.rotate(rotation.conjugate());
20 transformation.prerotate(rotation);
21 const auto origin = Kernel::toVector3d(componentInfo.position(componentIndex));
22 transformation.translate(-origin);
23 transformation.pretranslate(origin);
24
25 for (auto index : componentInfo.detectorsInSubtree(componentIndex)) {
26 auto newPos = Kernel::toV3D(transformation * Kernel::toVector3d(componentInfo.position(index)));
27 componentInfo.setPosition(index, newPos);
28 }
29}
30
31} // namespace Mantid::API
std::map< DeltaEMode::Type, std::string > index
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
ComponentInfo : Provides a component centric view on to the instrument.
Kernel::Quat rotation(const size_t componentIndex) const
Kernel::V3D position(const size_t componentIndex) const
std::vector< size_t > detectorsInSubtree(size_t componentIndex) const
void setPosition(size_t componentIndex, const Kernel::V3D &newPosition)
void conjugate()
Take the complex conjugate.
Definition Quat.cpp:357
MANTID_API_DLL void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, const size_t componentIndex, 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.