Mantid
|
Generic class to transform from M input dimensions to N output dimensions. More...
#include <CoordTransformAffine.h>
Public Member Functions | |
void | addTranslation (const coord_t *translationVector) |
Add a translation (in the output coordinates) to the transform. More... | |
void | apply (const coord_t *inputVector, coord_t *outVector) const override |
Apply the coordinate transformation. More... | |
void | buildNonOrthogonal (const Mantid::Kernel::VMD &origin, const std::vector< Mantid::Kernel::VMD > &axes, const Mantid::Kernel::VMD &scaling) |
void | buildOrthogonal (const Mantid::Kernel::VMD &origin, const std::vector< Mantid::Kernel::VMD > &axes, const Mantid::Kernel::VMD &scaling) |
Build a coordinate transformation based on an origin and orthogonal basis vectors. More... | |
CoordTransform * | clone () const override |
Virtual cloner. More... | |
CoordTransformAffine (const CoordTransformAffine &) | |
CoordTransformAffine (const size_t inD, const size_t outD) | |
Constructor. More... | |
const Mantid::Kernel::Matrix< coord_t > & | getMatrix () const |
Return the affine matrix in the transform. More... | |
std::string | id () const override |
Coordinate transform id. More... | |
Mantid::Kernel::Matrix< coord_t > | makeAffineMatrix () const override |
CoordTransformAffine & | operator= (CoordTransformAffine) |
void | setMatrix (const Mantid::Kernel::Matrix< coord_t > &newMatrix) |
Directly set the affine matrix to use. More... | |
std::string | toXMLString () const override |
Serialize the coordinate transform. More... | |
~CoordTransformAffine () override | |
Destructor. More... | |
Public Member Functions inherited from Mantid::API::CoordTransform | |
virtual void | apply (const coord_t *inputVector, coord_t *outVector) const =0 |
Mantid::Kernel::VMD | applyVMD (const Mantid::Kernel::VMD &inputVector) const |
Wrapper for VMD. More... | |
virtual CoordTransform * | clone () const =0 |
CoordTransform (const size_t inD, const size_t outD) | |
Constructor. More... | |
size_t | getInD () const |
size_t | getOutD () const |
virtual std::string | id () const =0 |
virtual Mantid::Kernel::Matrix< coord_t > | makeAffineMatrix () const |
virtual std::string | toXMLString () const =0 |
Pure abstract methods to be implemented. More... | |
virtual | ~CoordTransform ()=default |
Static Public Member Functions | |
static CoordTransformAffine * | combineTransformations (CoordTransform *first, CoordTransform *second) |
Combine two transformations into a single affine transformations. More... | |
Protected Member Functions | |
void | copyRawMatrix () |
Copies the affine matrix into a local raw pointer, for speed. More... | |
Protected Attributes | |
Mantid::Kernel::Matrix< coord_t > | m_affineMatrix |
Affine Matrix to perform the transformation. More... | |
coord_t ** | m_rawMatrix |
Raw pointer to the same underlying matrix as affineMatrix. More... | |
coord_t * | m_rawMemory |
raw pointer to the memory block, referred by the raw Matrix; More... | |
Protected Attributes inherited from Mantid::API::CoordTransform | |
size_t | inD |
Input number of dimensions. More... | |
size_t | outD |
Output number of dimensions. More... | |
Friends | |
void | swap (CoordTransformAffine &, CoordTransformAffine &) |
Generic class to transform from M input dimensions to N output dimensions.
The types of conversions to account for are:
This class could be subclassed in order to handle non-linear transforms (though making the apply() method virtual would disallow inlining = slowdown).
Definition at line 35 of file CoordTransformAffine.h.
Mantid::DataObjects::CoordTransformAffine::CoordTransformAffine | ( | const size_t | inD, |
const size_t | outD | ||
) |
Constructor.
Construct the affine matrix to and initialize to an identity matrix.
inD | :: input number of dimensions, >= 1 |
outD | :: output number of dimensions, <= inD |
std::runtime_error | if outD > inD |
Definition at line 32 of file CoordTransformAffine.cpp.
References copyRawMatrix(), Mantid::Kernel::Matrix< T >::identityMatrix(), m_affineMatrix, m_rawMatrix, m_rawMemory, Mantid::Kernel::Matrix< T >::numCols(), and Mantid::Kernel::Matrix< T >::numRows().
Mantid::DataObjects::CoordTransformAffine::CoordTransformAffine | ( | const CoordTransformAffine & | other | ) |
Definition at line 49 of file CoordTransformAffine.cpp.
References getMatrix(), and setMatrix().
|
override |
Destructor.
Definition at line 68 of file CoordTransformAffine.cpp.
References m_rawMatrix, and m_rawMemory.
void Mantid::DataObjects::CoordTransformAffine::addTranslation | ( | const coord_t * | translationVector | ) |
Add a translation (in the output coordinates) to the transform.
translationVector | :: fixed-size array of the translation vector, of size outD |
Definition at line 127 of file CoordTransformAffine.cpp.
References copyRawMatrix(), Mantid::Kernel::Matrix< T >::identityMatrix(), Mantid::API::CoordTransform::inD, m_affineMatrix, and Mantid::API::CoordTransform::outD.
|
overridevirtual |
Apply the coordinate transformation.
inputVector | :: fixed-size array of input coordinates, of size inD |
outVector | :: fixed-size array of output coordinates, of size outD |
Implements Mantid::API::CoordTransform.
Definition at line 273 of file CoordTransformAffine.cpp.
References Mantid::API::CoordTransform::inD, m_rawMatrix, and Mantid::API::CoordTransform::outD.
void Mantid::DataObjects::CoordTransformAffine::buildNonOrthogonal | ( | const Mantid::Kernel::VMD & | origin, |
const std::vector< Mantid::Kernel::VMD > & | axes, | ||
const Mantid::Kernel::VMD & | scaling | ||
) |
Definition at line 220 of file CoordTransformAffine.cpp.
References copyRawMatrix(), Mantid::Kernel::Matrix< T >::identityMatrix(), Mantid::API::CoordTransform::inD, Mantid::Kernel::Matrix< T >::Invert(), m_affineMatrix, Mantid::API::CoordTransform::outD, Mantid::Kernel::VMDBase< TYPE >::size(), and Mantid::Kernel::Matrix< T >::Transpose().
void Mantid::DataObjects::CoordTransformAffine::buildOrthogonal | ( | const Mantid::Kernel::VMD & | origin, |
const std::vector< Mantid::Kernel::VMD > & | axes, | ||
const Mantid::Kernel::VMD & | scaling | ||
) |
Build a coordinate transformation based on an origin and orthogonal basis vectors.
This can reduce the number of dimensions. For example:
And this allows us to create the affine matrix:
| Ux Uy Uz X0.U | | x | | u | | Vx Vy Vz X0.V | | y | = | v | | 0 0 0 1 | | z | | 1 | | 1 |
origin | :: origin (in the inDimension), which corresponds to (0,0,...) in outD |
axes | :: a list of basis vectors. There must be outD vectors (one for each output dimension) and each vector must be of length inD (all coordinates in the input dimension). The vectors must be properly orthogonal: not coplanar or collinear. This is not checked! |
scaling | :: a vector of size outD of the scaling to perform in each of the OUTPUT dimensions. |
if | inconsistent vector sizes are received, or zero-length |
Definition at line 173 of file CoordTransformAffine.cpp.
References copyRawMatrix(), Mantid::Kernel::Matrix< T >::identityMatrix(), Mantid::API::CoordTransform::inD, m_affineMatrix, Mantid::Kernel::VMDBase< TYPE >::normalize(), Mantid::API::CoordTransform::outD, and Mantid::Kernel::VMDBase< TYPE >::size().
|
overridevirtual |
Virtual cloner.
Implements Mantid::API::CoordTransform.
Definition at line 91 of file CoordTransformAffine.cpp.
References getMatrix(), Mantid::API::CoordTransform::inD, and Mantid::API::CoordTransform::outD.
|
static |
Combine two transformations into a single affine transformations.
first | :: CoordTransformAffine or CoordTransformAligned transform. |
second | :: CoordTransformAffine or CoordTransformAligned transform. |
std::runtime_error | if one of the inputs is not CoordTransformAffine or CoordTransformAligned |
Definition at line 346 of file CoordTransformAffine.cpp.
References Mantid::API::CoordTransform::getInD(), and Mantid::API::CoordTransform::getOutD().
|
protected |
Copies the affine matrix into a local raw pointer, for speed.
Call this after any change to affineMatrix
Definition at line 82 of file CoordTransformAffine.cpp.
References m_affineMatrix, m_rawMatrix, Mantid::Kernel::Matrix< T >::numCols(), Mantid::Kernel::Matrix< T >::numRows(), Mantid::Geometry::x, and Mantid::Geometry::y.
Referenced by addTranslation(), buildNonOrthogonal(), buildOrthogonal(), CoordTransformAffine(), and setMatrix().
const Mantid::Kernel::Matrix< coord_t > & Mantid::DataObjects::CoordTransformAffine::getMatrix | ( | ) | const |
Return the affine matrix in the transform.
Definition at line 116 of file CoordTransformAffine.cpp.
References m_affineMatrix.
Referenced by clone(), and CoordTransformAffine().
|
overridevirtual |
Coordinate transform id.
Implements Mantid::API::CoordTransform.
Definition at line 335 of file CoordTransformAffine.cpp.
|
overridevirtual |
Reimplemented from Mantid::API::CoordTransform.
Definition at line 119 of file CoordTransformAffine.cpp.
References m_affineMatrix.
CoordTransformAffine & Mantid::DataObjects::CoordTransformAffine::operator= | ( | CoordTransformAffine | other | ) |
Definition at line 60 of file CoordTransformAffine.cpp.
References swap.
void Mantid::DataObjects::CoordTransformAffine::setMatrix | ( | const Mantid::Kernel::Matrix< coord_t > & | newMatrix | ) |
Directly set the affine matrix to use.
newMatrix | :: (outD+1 * inD+1) matrix to set. |
runtime_error | if the matrix dimensions are incompatible. |
Definition at line 103 of file CoordTransformAffine.cpp.
References copyRawMatrix(), Mantid::API::CoordTransform::inD, m_affineMatrix, Mantid::Kernel::Matrix< T >::numCols(), Mantid::Kernel::Matrix< T >::numRows(), and Mantid::API::CoordTransform::outD.
Referenced by CoordTransformAffine(), and Mantid::MDAlgorithms::SlicingAlgorithm::createGeneralTransform().
|
overridevirtual |
Serialize the coordinate transform.
Implements Mantid::API::CoordTransform.
Definition at line 296 of file CoordTransformAffine.cpp.
References Mantid::API::CoordTransform::inD, m_affineMatrix, Mantid::API::CoordTransform::outD, Mantid::DataObjects::AffineMatrixParameter::setMatrix(), and Mantid::DataObjects::AffineMatrixParameter::toXMLString().
|
friend |
Definition at line 53 of file CoordTransformAffine.cpp.
Referenced by operator=().
|
protected |
Affine Matrix to perform the transformation.
The matrix has inD+1 columns, outD+1 rows. By using an affine, translations and rotations (or other linear transforms) can be combined by simply multiplying the matrices.
Definition at line 68 of file CoordTransformAffine.h.
Referenced by addTranslation(), buildNonOrthogonal(), buildOrthogonal(), CoordTransformAffine(), copyRawMatrix(), getMatrix(), makeAffineMatrix(), setMatrix(), and toXMLString().
|
protected |
Raw pointer to the same underlying matrix as affineMatrix.
Definition at line 71 of file CoordTransformAffine.h.
Referenced by apply(), CoordTransformAffine(), copyRawMatrix(), and ~CoordTransformAffine().
|
protected |
raw pointer to the memory block, referred by the raw Matrix;
Definition at line 73 of file CoordTransformAffine.h.
Referenced by CoordTransformAffine(), and ~CoordTransformAffine().