Mantid
Loading...
Searching...
No Matches
Quat.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 +
7#pragma once
8
9#include "MantidKernel/DllConfig.h"
11#include <string>
12#include <vector>
13
14namespace Mantid {
15namespace Kernel {
16template <class T> class Matrix;
17
38class MANTID_KERNEL_DLL Quat {
39
40public:
41 Quat();
42 // direct quat definition
43 Quat(const double _w, const double _a, const double _b, const double _c);
44 // * Construct a Quat between two vectors;
45 // * The angle between them is defined differently from usual if vectors are
46 // not unit or the same length vectors, so quat would be not consistent
47 Quat(const V3D &src, const V3D &des);
48 Quat(const V3D &rX, const V3D &rY, const V3D &rZ);
50 Quat(const double _deg, const V3D &_axis);
51 // set a quaternion from a rotational matrix;
52 Quat(const Matrix<double> &RotMat);
53 void operator()(const Quat &);
54 void operator()(const double ww, const double aa, const double bb, const double cc);
55 void operator()(const double angle, const V3D &);
56 void operator()(const V3D &rX, const V3D &rY, const V3D &rZ);
57
58 void set(const double ww, const double aa, const double bb, const double cc);
59 void setAngleAxis(const double _deg, const V3D &_axis);
60 void getAngleAxis(double &_deg, double &_ax0, double &_ax1, double &ax2) const;
61 std::vector<double> getEulerAngles(const std::string &convention) const;
63 void setRotation(const double deg);
65 double len() const;
67 double len2() const;
69 void init();
71 void normalize();
73 void conjugate();
75 void inverse();
77 bool isNull(const double tolerance = 0.001) const;
81 void GLMatrix(double *mat) const;
83 // vector representing M33 matrix
85 // if the mod(quat) is indeed == 1 and throws otherwise.
86 std::vector<double> getRotation(bool check_normalisation = false, bool throw_on_errors = false) const;
88 void setQuat(const double mat[16]);
90 // rotational;
91 void setQuat(const Matrix<double> &rMat);
93 void rotate(V3D &) const;
94
96 //(xmax,ymax,zmax)
97 // which means implicitly that the cube edges are parallel to the axes,
98 // find the smallest bounding box with the edges also parallel to the axes
99 // after rotation of the object.
100 void rotateBB(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const;
102 Quat operator+(const Quat &) const;
103 Quat &operator+=(const Quat &);
104 Quat operator-(const Quat &) const;
105 Quat &operator-=(const Quat &);
106 Quat operator*(const Quat &) const;
107 Quat &operator*=(const Quat &);
108 bool operator==(const Quat &) const;
109 bool operator!=(const Quat &) const;
110 double operator[](int) const;
111 double &operator[](int);
112
116 inline double real() const { return w; }
118 inline double imagI() const { return a; }
120 inline double imagJ() const { return b; }
122 inline double imagK() const { return c; }
124
125 void printSelf(std::ostream &) const;
126 void readPrinted(std::istream &);
127 std::string toString() const;
128 void fromString(const std::string &str);
129
130private:
132 double w;
134 double a;
136 double b;
138 double c;
139};
140
141MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &, const Quat &);
142MANTID_KERNEL_DLL std::istream &operator>>(std::istream &, Quat &q);
143
144} // namespace Kernel
145
146} // namespace Mantid
void(ComponentInfo::* setRotation)(const size_t, const Mantid::Kernel::Quat &)
std::vector< double > getAngleAxis(Quat &self)
Extracts the angle of rotation and axis.
Definition Quat.cpp:26
double tolerance
Numerical Matrix class.
Definition Matrix.h:41
Class for quaternions.
Definition Quat.h:38
double c
Internal value.
Definition Quat.h:138
double b
Internal value.
Definition Quat.h:136
double imagJ() const
Access the coefficient of j.
Definition Quat.h:120
double w
Internal value.
Definition Quat.h:132
double real() const
Access the real part.
Definition Quat.h:116
double imagI() const
Access the coefficient of i.
Definition Quat.h:118
double a
Internal value.
Definition Quat.h:134
double imagK() const
Access the coefficient of k.
Definition Quat.h:122
Class for 3D vectors.
Definition V3D.h:35
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Subtracts two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
MANTID_KERNEL_DLL std::ostream & operator<<(std::ostream &, CPUTimer &)
Convenience function to provide for easier debug printing.
Definition CPUTimer.cpp:86
MANTID_KERNEL_DLL std::istream & operator>>(std::istream &, Interpolation &)
Reads in parameter value.
std::string toString(const T &value)
Convert values to strings.
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
Definition V3D.h:353
Helper class which provides the Collimation Length for SANS instruments.
constexpr wide_integer< Bits, Signed > operator-(const wide_integer< Bits, Signed > &lhs) noexcept(is_same< Signed, unsigned >::value)
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator*(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator+(const wide_integer< Bits, Signed > &lhs) noexcept(is_same< Signed, unsigned >::value)