OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
CoordinateSystemTrafo.h
Go to the documentation of this file.
1#ifndef COORDINATESYSTEMTRAFO
2#define COORDINATESYSTEMTRAFO
3
4#include "Algorithms/Vektor.h"
6#include "AppTypes/Tenzor.h"
7
9public:
11
13
14 CoordinateSystemTrafo(const Vector_t &origin,
15 const Quaternion &orientation);
16
17 Vector_t transformTo(const Vector_t &r) const;
18 Vector_t transformFrom(const Vector_t &r) const;
19
20 Vector_t rotateTo(const Vector_t &r) const;
21 Vector_t rotateFrom(const Vector_t &r) const;
22
23 void invert();
25
28 void operator*=(const CoordinateSystemTrafo &right);
29
30 Vector_t getOrigin() const;
31 Quaternion getRotation() const;
32
33 void print(std::ostream&) const;
34private:
38};
39
40inline
41std::ostream& operator<<(std::ostream& os, const CoordinateSystemTrafo &trafo) {
42 trafo.print(os);
43 return os;
44}
45
46inline
48 trafo.print(os.getStream());
49 return os;
50}
51
52inline
53void CoordinateSystemTrafo::print(std::ostream &os) const {
54 os << "Origin: " << origin_m << "\n"
55 << "z-axis: " << orientation_m.conjugate().rotate(Vector_t(0,0,1)) << "\n"
56 << "x-axis: " << orientation_m.conjugate().rotate(Vector_t(1,0,0));
57}
58
59inline
61 return origin_m;
62}
63
64inline
66 return orientation_m;
67}
68
69inline
71 CoordinateSystemTrafo result(*this);
72 result.invert();
73
74 return result;
75}
76
77inline
79 return dot(rotationMatrix_m, r - origin_m);
80}
81
82inline
85}
86
87inline
89 return dot(rotationMatrix_m, r);
90}
91
92inline
94 return dot(transpose(rotationMatrix_m), r);
95}
96
97#endif
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition: Vector3D.cpp:118
std::ostream & operator<<(std::ostream &os, const CoordinateSystemTrafo &trafo)
AntiSymTenzor< T, D > transpose(const AntiSymTenzor< T, D > &rhs)
Tenzor< double, 3 > rotationMatrix_m
void operator*=(const CoordinateSystemTrafo &right)
Vector_t rotateFrom(const Vector_t &r) const
CoordinateSystemTrafo & operator=(const CoordinateSystemTrafo &right)=default
Vector_t transformFrom(const Vector_t &r) const
Vector_t transformTo(const Vector_t &r) const
Vector_t rotateTo(const Vector_t &r) const
void print(std::ostream &) const
CoordinateSystemTrafo inverted() const
CoordinateSystemTrafo operator*(const CoordinateSystemTrafo &right) const
Quaternion getRotation() const
Vector_t rotate(const Vector_t &) const
Definition: Quaternion.cpp:122
Quaternion conjugate() const
Definition: Quaternion.h:105
Definition: Inform.h:42
std::ostream & getStream()
Definition: Inform.h:89
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6