OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
CoordinateSystemTrafo.cpp
Go to the documentation of this file.
2
4 : origin_m(0.0), orientation_m(1.0, 0.0, 0.0, 0.0), rotationMatrix_m() {
5 // Default constructor of matrix3x3_t already initializes to identity
6 // But we can explicitly set it if needed (redundant but clear)
7 rotationMatrix_m(0, 0) = 1.0;
8 rotationMatrix_m(0, 1) = 0.0;
9 rotationMatrix_m(0, 2) = 0.0;
10 rotationMatrix_m(1, 0) = 0.0;
11 rotationMatrix_m(1, 1) = 1.0;
12 rotationMatrix_m(1, 2) = 0.0;
13 rotationMatrix_m(2, 0) = 0.0;
14 rotationMatrix_m(2, 1) = 0.0;
15 rotationMatrix_m(2, 2) = 1.0;
16}
17
19 : origin_m(right.origin_m),
20 orientation_m(right.orientation_m),
21 rotationMatrix_m(right.rotationMatrix_m) {}
22
24 const ippl::Vector<double, 3>& origin, const Quaternion& orientation)
25 : origin_m(origin),
26 orientation_m(orientation),
27 rotationMatrix_m(orientation_m.getRotationMatrix()) {}
28
34
36 CoordinateSystemTrafo result(*this);
37
38 result *= right;
39 return result;
40}
41
48
49/* ====================== Transformation Functions ========================== */
50/*
51void CoordinateSystemTrafo::transformBunchTo(auto Rview)
52{
53 // local copies for the kernel
54 auto rotationMatrix = rotationMatrix_m;
55 auto origin = origin_m;
56 Kokkos::parallel_for("transformBunchTo()", ippl::getRangePolicy(Rview),
57 KOKKOS_LAMBDA(const int i)
58 {
59 const ippl::Vector<double, 3> delta = Rview(i) - origin;
60 Rview(i) = prod_vector(rotationMatrix,delta);
61 });
62}
63
64void CoordinateSystemTrafo::transformBunchFrom(auto Rview)
65{
66 // local copies for the kernel
67 auto rotationMatrix = rotationMatrix_m;
68 auto origin = origin_m;
69 Kokkos::parallel_for("transformBunchFrom()", ippl::getRangePolicy(Rview),
70 KOKKOS_LAMBDA(const int i)
71 {
72 Rview(i) = prod_vector_transpose(rotationMatrix, Rview(i)) + origin;
73 });
74}
75
76void CoordinateSystemTrafo::rotateBunchTo(auto Pview)
77{
78 // local copy for the kernel
79 auto rotationMatrix = rotationMatrix_m;
80 Kokkos::parallel_for("rotateBunchTo()", ippl::getRangePolicy(Pview),
81 KOKKOS_LAMBDA(const int i)
82 {
83 Pview(i) = prod_vector(rotationMatrix, Pview(i));
84 });
85}
86
87void CoordinateSystemTrafo::rotateBunchFrom(auto Pview)
88{
89 // local copy for the kernel
90 auto rotationMatrix = rotationMatrix_m;
91 Kokkos::parallel_for("rotateBunchFrom()", ippl::getRangePolicy(Pview),
92 KOKKOS_LAMBDA(const int i)
93 {
94 Pview(i) = prod_vector_transpose(rotationMatrix, Pview(i));
95 });
96}
97*/
98
99/* ========================================================================== */
100/* ============================ Getters ===================================== */
101
102/* ========================================================================== */
KOKKOS_INLINE_FUNCTION matrix_t< Cols, Rows > get_transpose(const matrix_t< Rows, Cols > &rotation)
Definition Matrix.h:139
Rigid spatial transform between a parent frame and a local frame.
matrix3x3_t rotationMatrix_m
Cached rotation matrix for the same parent-to-local mapping.
CoordinateSystemTrafo()
Construct the identity transform.
void operator*=(const CoordinateSystemTrafo &right)
ippl::Vector< double, 3 > origin_m
Local origin expressed in the parent frame.
CoordinateSystemTrafo operator*(const CoordinateSystemTrafo &right) const
Compose two transforms.
Quaternion orientation_m
Quaternion whose rotation maps parent-frame vectors into local-frame vectors.
void invert()
Invert the transform in place.
Quaternion storage and rotation algebra used by OPALX geometry code.
Quaternion & normalize()
Normalize the quaternion in place.
Quaternion conjugate() const
Return the quaternion conjugate .
matrix3x3_t getRotationMatrix() const
Convert the quaternion to a 3x3 rotation matrix.
ippl::Vector< double, 3 > rotate(const ippl::Vector< double, 3 > &) const
Rotate a spatial vector by a unit quaternion.