Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Mantid::DataObjects::CoordTransformAffine Class Reference

Generic class to transform from M input dimensions to N output dimensions. More...

#include <CoordTransformAffine.h>

Inheritance diagram for Mantid::DataObjects::CoordTransformAffine:
Mantid::API::CoordTransform

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...
 
CoordTransformclone () 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_tmakeAffineMatrix () const override
 
CoordTransformAffineoperator= (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 CoordTransformclone () 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_tmakeAffineMatrix () const
 
virtual std::string toXMLString () const =0
 Pure abstract methods to be implemented. More...
 
virtual ~CoordTransform ()=default
 

Static Public Member Functions

static CoordTransformAffinecombineTransformations (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_tm_affineMatrix
 Affine Matrix to perform the transformation. More...
 
coord_t ** m_rawMatrix
 Raw pointer to the same underlying matrix as affineMatrix. More...
 
coord_tm_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 &)
 

Detailed Description

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).

Author
Janik Zikovsky
Date
2011-04-14 10:03:55.944809

Definition at line 35 of file CoordTransformAffine.h.

Constructor & Destructor Documentation

◆ CoordTransformAffine() [1/2]

Mantid::DataObjects::CoordTransformAffine::CoordTransformAffine ( const size_t  inD,
const size_t  outD 
)

Constructor.

Construct the affine matrix to and initialize to an identity matrix.

Parameters
inD:: input number of dimensions, >= 1
outD:: output number of dimensions, <= inD
Exceptions
std::runtime_errorif 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().

◆ CoordTransformAffine() [2/2]

Mantid::DataObjects::CoordTransformAffine::CoordTransformAffine ( const CoordTransformAffine other)

Definition at line 49 of file CoordTransformAffine.cpp.

References getMatrix(), and setMatrix().

◆ ~CoordTransformAffine()

Mantid::DataObjects::CoordTransformAffine::~CoordTransformAffine ( )
override

Destructor.

Definition at line 68 of file CoordTransformAffine.cpp.

References m_rawMatrix, and m_rawMemory.

Member Function Documentation

◆ addTranslation()

void Mantid::DataObjects::CoordTransformAffine::addTranslation ( const coord_t translationVector)

Add a translation (in the output coordinates) to the transform.

Parameters
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.

◆ apply()

void Mantid::DataObjects::CoordTransformAffine::apply ( const coord_t inputVector,
coord_t outVector 
) const
overridevirtual

Apply the coordinate transformation.

Parameters
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.

◆ buildNonOrthogonal()

void Mantid::DataObjects::CoordTransformAffine::buildNonOrthogonal ( const Mantid::Kernel::VMD origin,
const std::vector< Mantid::Kernel::VMD > &  axes,
const Mantid::Kernel::VMD scaling 
)

◆ buildOrthogonal()

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:

  • The input position is X=(x,y,z)
  • The origin is X0=(x0,y0,z0)
  • The basis vectors are U and V (reducing from 3 to 2D)
  • The output position u = (X-X0).U = X.U - X0.U = x*Ux + y*Uy + z*Uz + (X0.U)
  • The output position v = (X-X0).V = X.V - X0.V = x*Vx + y*Vy + z*Vz + (X0.V)

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 |

Parameters
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.
Exceptions
ifinconsistent 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().

◆ clone()

CoordTransform * Mantid::DataObjects::CoordTransformAffine::clone ( ) const
overridevirtual

Virtual cloner.

Returns
a copy of this object

Implements Mantid::API::CoordTransform.

Definition at line 91 of file CoordTransformAffine.cpp.

References getMatrix(), Mantid::API::CoordTransform::inD, and Mantid::API::CoordTransform::outD.

◆ combineTransformations()

CoordTransformAffine * Mantid::DataObjects::CoordTransformAffine::combineTransformations ( CoordTransform first,
CoordTransform second 
)
static

Combine two transformations into a single affine transformations.

Parameters
first:: CoordTransformAffine or CoordTransformAligned transform.
second:: CoordTransformAffine or CoordTransformAligned transform.
Returns
pointer to a new CoordTransformAffine combining both
Exceptions
std::runtime_errorif 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().

◆ copyRawMatrix()

void Mantid::DataObjects::CoordTransformAffine::copyRawMatrix ( )
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().

◆ getMatrix()

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().

◆ id()

std::string Mantid::DataObjects::CoordTransformAffine::id ( ) const
overridevirtual

Coordinate transform id.

Returns
the type of coordinate transform

Implements Mantid::API::CoordTransform.

Definition at line 335 of file CoordTransformAffine.cpp.

◆ makeAffineMatrix()

Mantid::Kernel::Matrix< coord_t > Mantid::DataObjects::CoordTransformAffine::makeAffineMatrix ( ) const
overridevirtual
Returns
the affine matrix

Reimplemented from Mantid::API::CoordTransform.

Definition at line 119 of file CoordTransformAffine.cpp.

References m_affineMatrix.

◆ operator=()

CoordTransformAffine & Mantid::DataObjects::CoordTransformAffine::operator= ( CoordTransformAffine  other)

Definition at line 60 of file CoordTransformAffine.cpp.

References swap.

◆ setMatrix()

void Mantid::DataObjects::CoordTransformAffine::setMatrix ( const Mantid::Kernel::Matrix< coord_t > &  newMatrix)

Directly set the affine matrix to use.

Parameters
newMatrix:: (outD+1 * inD+1) matrix to set.
Exceptions
runtime_errorif 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().

◆ toXMLString()

std::string Mantid::DataObjects::CoordTransformAffine::toXMLString ( ) const
overridevirtual

Friends And Related Function Documentation

◆ swap

void swap ( CoordTransformAffine obj1,
CoordTransformAffine obj2 
)
friend

Definition at line 53 of file CoordTransformAffine.cpp.

Referenced by operator=().

Member Data Documentation

◆ m_affineMatrix

Mantid::Kernel::Matrix<coord_t> Mantid::DataObjects::CoordTransformAffine::m_affineMatrix
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().

◆ m_rawMatrix

coord_t** Mantid::DataObjects::CoordTransformAffine::m_rawMatrix
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().

◆ m_rawMemory

coord_t* Mantid::DataObjects::CoordTransformAffine::m_rawMemory
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().


The documentation for this class was generated from the following files: