|
Mantid
|
Simple vector class for multiple dimensions (i.e. More...
#include <VMD.h>
Public Member Functions | |
| TYPE | angle (const VMDBase &v) const |
| Return the angle between this and another vector. More... | |
| VMDBase | cross_prod (const VMDBase &v) const |
| Cross product of two vectors. More... | |
| const TYPE * | getBareArray () const |
| size_t | getNumDims () const |
| TYPE | length () const |
| TYPE | norm () const |
| TYPE | norm2 () const |
| TYPE | normalize () |
| Normalize this vector to unity length. More... | |
| bool | operator!= (const VMDBase &v) const |
| Not-equals operator with tolerance factor. More... | |
| VMDBase | operator* (const double scalar) const |
| Multiply by a scalar. More... | |
| VMDBase | operator* (const VMDBase &v) const |
| Inner product of two vectors (element-by-element) More... | |
| VMDBase & | operator*= (const double scalar) |
| Multiply by a scalar. More... | |
| VMDBase & | operator*= (const VMDBase &v) |
| Inner product of two vectors (element-by-element) More... | |
| VMDBase | operator+ (const VMDBase &v) const |
| Add two vectors together. More... | |
| VMDBase & | operator+= (const VMDBase &v) |
| Add two vectors together. More... | |
| VMDBase | operator- (const VMDBase &v) const |
| Subtract two vectors. More... | |
| VMDBase & | operator-= (const VMDBase &v) |
| Subtract two vectors. More... | |
| VMDBase | operator/ (const double scalar) const |
| Divide by a scalar. More... | |
| VMDBase | operator/ (const VMDBase &v) const |
| Inner division of two vectors (element-by-element) More... | |
| VMDBase & | operator/= (const double scalar) |
| Divide by a scalar. More... | |
| VMDBase & | operator/= (const VMDBase &v) |
| Inner division of two vectors (element-by-element) More... | |
| VMDBase & | operator= (const VMDBase &other) |
| Assignment operator. More... | |
| VMDBase & | operator= (VMDBase &&other) noexcept |
| Move assignment. More... | |
| bool | operator== (const VMDBase &v) const |
| Equals operator with tolerance factor. More... | |
| TYPE & | operator[] (const size_t index) |
| const TYPE & | operator[] (const size_t index) const |
| TYPE | scalar_prod (const VMDBase &v) const |
| Scalar product of two vectors. More... | |
| size_t | size () const |
| std::string | toString (const std::string &separator=" ") const |
| Return a simple string representation of the vector. More... | |
| VMDBase () | |
| Default constructor, build with 1 dimension. More... | |
| VMDBase (const std::string &str) | |
| Constructor from string. More... | |
| VMDBase (const std::vector< double > &vector) | |
| Constructor. More... | |
| VMDBase (const std::vector< float > &vector) | |
| Constructor. More... | |
| VMDBase (const V3D &vector) | |
| Constructor. More... | |
| VMDBase (const VMDBase &other) | |
| Copy constructor. More... | |
| VMDBase (double val0, double val1) | |
| 2D Constructor More... | |
| VMDBase (double val0, double val1, double val2) | |
| 3D Constructor More... | |
| VMDBase (double val0, double val1, double val2, double val3) | |
| 4D Constructor More... | |
| VMDBase (double val0, double val1, double val2, double val3, double val4) | |
| 5D Constructor More... | |
| VMDBase (double val0, double val1, double val2, double val3, double val4, double val5) | |
| 6D Constructor More... | |
| VMDBase (size_t nd) | |
| Constructor. More... | |
| VMDBase (size_t nd, const double *bareData) | |
| Constructor. More... | |
| VMDBase (size_t nd, const float *bareData) | |
| Constructor. More... | |
| VMDBase (VMDBase &&other) noexcept | |
| Move constructor. More... | |
| ~VMDBase () | |
| Destructor. More... | |
Static Public Member Functions | |
| static VMDBase | getNormalVector (const std::vector< VMDBase > &vectors) |
| Given N-1 vectors defining a N-1 dimensional hyperplane in N dimensions, returns a vector that is normal (perpendicular) to all the input vectors. More... | |
| static std::vector< VMDBase > | makeVectorsOrthogonal (std::vector< VMDBase > &vectors) |
| Make an orthogonal system with 2 input 3D vectors. More... | |
Protected Attributes | |
| TYPE * | data |
| Data, an array of size nd. More... | |
| size_t | nd |
| Number of dimensions. More... | |
Simple vector class for multiple dimensions (i.e.
> 3).
| Mantid::Kernel::VMDBase< TYPE >::VMDBase |
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | size_t | nd | ) |
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | double | val0, |
| double | val1 | ||
| ) |
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | double | val0, |
| double | val1, | ||
| double | val2 | ||
| ) |
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | double | val0, |
| double | val1, | ||
| double | val2, | ||
| double | val3 | ||
| ) |
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | double | val0, |
| double | val1, | ||
| double | val2, | ||
| double | val3, | ||
| double | val4 | ||
| ) |
5D Constructor
| val0 | :: value at first dimension |
| val1 | :: value at second dimension |
| val2 | :: value at third dimension |
| val3 | :: value at fourth dimension |
| val4 | :: value at fifth dimension |
Definition at line 86 of file VMD.cpp.
References Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | double | val0, |
| double | val1, | ||
| double | val2, | ||
| double | val3, | ||
| double | val4, | ||
| double | val5 | ||
| ) |
6D Constructor
| val0 | :: value at first dimension |
| val1 | :: value at second dimension |
| val2 | :: value at third dimension |
| val3 | :: value at fourth dimension |
| val4 | :: value at fifth dimension |
| val5 | :: value at sixth dimension |
Definition at line 104 of file VMD.cpp.
References Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
Copy constructor.
| other | :: other to copy |
Definition at line 116 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | size_t | nd, |
| const double * | bareData | ||
| ) |
Constructor.
| nd | :: number of dimensions |
| bareData | :: pointer to a nd-sized bare data array |
Definition at line 163 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | size_t | nd, |
| const float * | bareData | ||
| ) |
Constructor.
| nd | :: number of dimensions |
| bareData | :: pointer to a nd-sized bare data array |
Definition at line 174 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | const V3D & | vector | ) |
Constructor.
| vector | :: V3D |
Definition at line 184 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | const std::vector< double > & | vector | ) |
Constructor.
| vector | :: vector of doubles |
Definition at line 192 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | const std::vector< float > & | vector | ) |
Constructor.
| vector | :: vector of floats |
Definition at line 202 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| Mantid::Kernel::VMDBase< TYPE >::VMDBase | ( | const std::string & | str | ) |
Constructor from string.
| str | :: string of comma or space-separated numbers for each component |
Definition at line 213 of file VMD.cpp.
References Mantid::Kernel::StringTokenizer::cbegin(), Mantid::Kernel::StringTokenizer::cend(), and Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY.
| Mantid::Kernel::VMDBase< TYPE >::~VMDBase |
| TYPE Mantid::Kernel::VMDBase< TYPE >::angle | ( | const VMDBase< TYPE > & | v | ) | const |
Return the angle between this and another vector.
| v | :: The other vector |
Definition at line 438 of file VMD.cpp.
References Mantid::Kernel::VMDBase< TYPE >::norm().
| VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::cross_prod | ( | const VMDBase< TYPE > & | v | ) | const |
Cross product of two vectors.
Only works in 3D
| v | :: other vector, also 3D |
Definition at line 403 of file VMD.cpp.
References Mantid::Kernel::V3D::cross_prod(), Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| const TYPE * Mantid::Kernel::VMDBase< TYPE >::getBareArray |
Definition at line 248 of file VMD.cpp.
Referenced by Mantid::API::CoordTransform::applyVMD(), Mantid::API::IMDWorkspace::getLinePlot(), Mantid::API::IMDWorkspace::getSignalAtVMD(), and Mantid::API::IMDWorkspace::getSignalWithMaskAtVMD().
|
static |
Given N-1 vectors defining a N-1 dimensional hyperplane in N dimensions, returns a vector that is normal (perpendicular) to all the input vectors.
Given planar vectors a, b, c, ... Build a NxN matrix of this style: x1 x2 x3 x4 a1 a2 a4 a4 b1 b2 b4 b4 c1 c2 c4 c4
Where xn = the basis unit vector of the space, e.g. x1 = x, x2 = y, etc.
The determinant of the matrix gives the normal vector. This is analogous to the determinant method of finding the cross product of 2 3D vectors.
It can be shown that the resulting vector n is such that: n . a = 0; n . b = 0 etc. ... meaning that all the in-plane vectors are perpendicular to the normal, which is what we wanted!
(I've worked it out in 4D and its a long proof (not shown here) I'm assuming it holds for higher dimensions, I'll let a mathematician prove this :) )
| vectors | :: vector of N-1 vectors with N dimensions. |
| if | the vectors are collinear |
Definition at line 494 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::Matrix< T >::determinant(), and Mantid::Kernel::VMDBase< TYPE >::normalize().
| size_t Mantid::Kernel::VMDBase< TYPE >::getNumDims |
Definition at line 236 of file VMD.cpp.
Referenced by Mantid::API::CoordTransform::applyVMD(), Mantid::DataObjects::MDHistoWorkspace::getLinePoints(), Mantid::Geometry::MDPlane::MDPlane(), and Mantid::MDAlgorithms::SlicingAlgorithm::processGeneralTransformProperties().
| TYPE Mantid::Kernel::VMDBase< TYPE >::length |
|
static |
Make an orthogonal system with 2 input 3D vectors.
Currently only works in 3D!
| vectors | :: list of 2 vectors with 3D |
Definition at line 450 of file VMD.cpp.
References Mantid::Kernel::V3D::makeVectorsOrthogonal().
| TYPE Mantid::Kernel::VMDBase< TYPE >::norm |
Definition at line 420 of file VMD.cpp.
Referenced by Mantid::Kernel::VMDBase< TYPE >::angle(), Mantid::API::IMDWorkspace::getLinePlot(), and Mantid::MDAlgorithms::SlicingAlgorithm::makeBasisVectorFromString().
| TYPE Mantid::Kernel::VMDBase< TYPE >::norm2 |
| TYPE Mantid::Kernel::VMDBase< TYPE >::normalize |
Normalize this vector to unity length.
Definition at line 427 of file VMD.cpp.
References Mantid::Geometry::d.
Referenced by Mantid::DataObjects::CoordTransformAffine::buildOrthogonal(), Mantid::DataObjects::MDHistoWorkspace::getLinePoints(), Mantid::Kernel::VMDBase< TYPE >::getNormalVector(), Mantid::MDAlgorithms::ConvertMDHistoToMatrixWorkspace::make1DWorkspace(), and Mantid::MDAlgorithms::SlicingAlgorithm::makeBasisVectorFromString().
| bool Mantid::Kernel::VMDBase< TYPE >::operator!= | ( | const VMDBase< TYPE > & | v | ) | const |
Not-equals operator with tolerance factor.
| v | :: VMDBase for comparison |
Definition at line 278 of file VMD.cpp.
References Mantid::Kernel::operator==().
| VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator* | ( | const double | scalar | ) | const |
| VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator*= | ( | const double | scalar | ) |
Multiply by a scalar.
| scalar | :: double scalar to multiply each element |
Definition at line 367 of file VMD.cpp.
References Mantid::Geometry::d.
| VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator*= | ( | const VMDBase< TYPE > & | v | ) |
Inner product of two vectors (element-by-element)
| v | :: other vector, must match number of dimensions |
Definition at line 329 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator+= | ( | const VMDBase< TYPE > & | v | ) |
Add two vectors together.
| v | :: other vector, must match number of dimensions |
Definition at line 290 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator-= | ( | const VMDBase< TYPE > & | v | ) |
Subtract two vectors.
| v | :: other vector, must match number of dimensions |
Definition at line 310 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator/ | ( | const double | scalar | ) | const |
| VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator/= | ( | const double | scalar | ) |
Divide by a scalar.
| scalar | :: double scalar to Divide each element |
Definition at line 383 of file VMD.cpp.
References Mantid::Geometry::d.
| VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator/= | ( | const VMDBase< TYPE > & | v | ) |
Inner division of two vectors (element-by-element)
| v | :: other vector, must match number of dimensions |
Definition at line 348 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
| VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator= | ( | const VMDBase< TYPE > & | other | ) |
Assignment operator.
| other | :: copy into this |
Definition at line 127 of file VMD.cpp.
References Mantid::Geometry::d.
| bool Mantid::Kernel::VMDBase< TYPE >::operator== | ( | const VMDBase< TYPE > & | v | ) | const |
Equals operator with tolerance factor.
| v | :: VMDBase for comparison |
Definition at line 265 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, Mantid::Kernel::VMDBase< TYPE >::nd, and Mantid::Kernel::Tolerance.
| TYPE & Mantid::Kernel::VMDBase< TYPE >::operator[] | ( | const size_t | index | ) |
| const TYPE & Mantid::Kernel::VMDBase< TYPE >::operator[] | ( | const size_t | index | ) | const |
| TYPE Mantid::Kernel::VMDBase< TYPE >::scalar_prod | ( | const VMDBase< TYPE > & | v | ) | const |
Scalar product of two vectors.
| v | :: other vector, must match number of dimensions |
Definition at line 391 of file VMD.cpp.
References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.
Referenced by Mantid::MDAlgorithms::SlicingAlgorithm::isProjectingOnFrame().
| size_t Mantid::Kernel::VMDBase< TYPE >::size |
Definition at line 239 of file VMD.cpp.
Referenced by Mantid::DataObjects::CoordTransformAffine::buildNonOrthogonal(), Mantid::DataObjects::CoordTransformAffine::buildOrthogonal(), Mantid::Geometry::MDBoxImplicitFunction::construct(), Mantid::Geometry::MDBoxImplicitFunction::fraction(), and Mantid::MDAlgorithms::SlicingAlgorithm::getGeneralImplicitFunction().
| std::string Mantid::Kernel::VMDBase< TYPE >::toString | ( | const std::string & | separator = " " | ) | const |
Return a simple string representation of the vector.
| separator | :: string to place between values, one space is the default |
Definition at line 254 of file VMD.cpp.
References Mantid::Geometry::d.
Referenced by Mantid::Kernel::operator<<().
|
protected |
Data, an array of size nd.
Definition at line 79 of file VMD.h.
Referenced by Mantid::Kernel::VMDBase< VMD_t >::angle(), Mantid::Kernel::VMDBase< TYPE >::cross_prod(), Mantid::Kernel::VMDBase< TYPE >::operator*=(), Mantid::Kernel::VMDBase< TYPE >::operator+=(), Mantid::Kernel::VMDBase< TYPE >::operator-=(), Mantid::Kernel::VMDBase< TYPE >::operator/=(), Mantid::Kernel::VMDBase< TYPE >::operator==(), Mantid::Kernel::VMDBase< TYPE >::scalar_prod(), and Mantid::Kernel::VMDBase< TYPE >::VMDBase().
|
protected |
Number of dimensions.
Definition at line 77 of file VMD.h.
Referenced by Mantid::Kernel::VMDBase< VMD_t >::angle(), Mantid::Kernel::VMDBase< TYPE >::cross_prod(), Mantid::Kernel::VMDBase< TYPE >::operator*=(), Mantid::Kernel::VMDBase< TYPE >::operator+=(), Mantid::Kernel::VMDBase< TYPE >::operator-=(), Mantid::Kernel::VMDBase< TYPE >::operator/=(), Mantid::Kernel::VMDBase< TYPE >::operator==(), Mantid::Kernel::VMDBase< TYPE >::scalar_prod(), and Mantid::Kernel::VMDBase< TYPE >::VMDBase().