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"
10#include <string>
11#include <vector>
12
13namespace Mantid {
14namespace Kernel {
15// Forward declarations
16class V3D;
17template <class T> class Matrix;
18
39class MANTID_KERNEL_DLL Quat {
40
41public:
42 Quat();
43 // direct quat definition
44 Quat(const double _w, const double _a, const double _b, const double _c);
45 // * Construct a Quat between two vectors;
46 // * The angle between them is defined differently from usual if vectors are
47 // not unit or the same length vectors, so quat would be not consistent
48 Quat(const V3D &src, const V3D &des);
49 Quat(const V3D &rX, const V3D &rY, const V3D &rZ);
51 Quat(const double _deg, const V3D &_axis);
52 // set a quaternion from a rotational matrix;
53 Quat(const Matrix<double> &RotMat);
54 void operator()(const Quat &);
55 void operator()(const double ww, const double aa, const double bb, const double cc);
56 void operator()(const double angle, const V3D &);
57 void operator()(const V3D &rX, const V3D &rY, const V3D &rZ);
58
59 void set(const double ww, const double aa, const double bb, const double cc);
60 void setAngleAxis(const double _deg, const V3D &_axis);
61 void getAngleAxis(double &_deg, double &_ax0, double &_ax1, double &ax2) const;
62 std::vector<double> getEulerAngles(const std::string &convention) const;
64 void setRotation(const double deg);
66 double len() const;
68 double len2() const;
70 void init();
72 void normalize();
74 void conjugate();
76 void inverse();
78 bool isNull(const double tolerance = 0.001) const;
82 void GLMatrix(double *mat) const;
84 // vector representing M33 matrix
86 // if the mod(quat) is indeed == 1 and throws otherwise.
87 std::vector<double> getRotation(bool check_normalisation = false, bool throw_on_errors = false) const;
89 void setQuat(double mat[16]);
91 // rotational;
92 void setQuat(const Matrix<double> &rMat);
94 void rotate(V3D &) const;
95
97 //(xmax,ymax,zmax)
98 // which means implicitly that the cube edges are parallel to the axes,
99 // find the smallest bounding box with the edges also parallel to the axes
100 // after rotation of the object.
101 void rotateBB(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const;
103 Quat operator+(const Quat &) const;
104 Quat &operator+=(const Quat &);
105 Quat operator-(const Quat &) const;
106 Quat &operator-=(const Quat &);
107 Quat operator*(const Quat &) const;
108 Quat &operator*=(const Quat &);
109 bool operator==(const Quat &) const;
110 bool operator!=(const Quat &) const;
111 double operator[](int) const;
112 double &operator[](int);
113
117 inline double real() const { return w; }
119 inline double imagI() const { return a; }
121 inline double imagJ() const { return b; }
123 inline double imagK() const { return c; }
125
126 void printSelf(std::ostream &) const;
127 void readPrinted(std::istream &);
128 std::string toString() const;
129 void fromString(const std::string &str);
130
131private:
133 double w;
135 double a;
137 double b;
139 double c;
140};
141
142MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &, const Quat &);
143MANTID_KERNEL_DLL std::istream &operator>>(std::istream &, Quat &q);
144
145} // namespace Kernel
146
147} // namespace Mantid
void(ComponentInfo::* setRotation)(const size_t, const Mantid::Kernel::Quat &)
double tolerance
Numerical Matrix class.
Definition: Matrix.h:42
Class for quaternions.
Definition: Quat.h:39
double c
Internal value.
Definition: Quat.h:139
double b
Internal value.
Definition: Quat.h:137
double imagJ() const
Access the coefficient of j.
Definition: Quat.h:121
double w
Internal value.
Definition: Quat.h:133
double real() const
Access the real part.
Definition: Quat.h:117
double imagI() const
Access the coefficient of i.
Definition: Quat.h:119
double a
Internal value.
Definition: Quat.h:135
double imagK() const
Access the coefficient of k.
Definition: Quat.h:123
Class for 3D vectors.
Definition: V3D.h:34
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
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)
Subtracts two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds 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.
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
Definition: V3D.h:341
Helper class which provides the Collimation Length for SANS instruments.
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)