1#ifndef COORDINATESYSTEMTRAFO
2#define COORDINATESYSTEMTRAFO
4#include <Kokkos_Core.hpp>
65 ippl::Vector<double, 3>
transformTo(
const ippl::Vector<double, 3>& r)
const;
68 ippl::Vector<double, 3>
transformFrom(
const ippl::Vector<double, 3>& r)
const;
71 ippl::Vector<double, 3>
rotateTo(
const ippl::Vector<double, 3>& r)
const;
74 ippl::Vector<double, 3>
rotateFrom(
const ippl::Vector<double, 3>& r)
const;
82 template <
typename ViewType>
86 template <
typename ViewType>
90 template <
typename ViewType>
94 template <
typename ViewType>
113 ippl::Vector<double, 3>
getOrigin()
const;
118 void print(std::ostream&)
const;
138 trafo.
print(os.getStream());
143 os <<
"Origin: " <<
origin_m <<
"\n"
149 const ippl::Vector<double, 3>& r)
const {
150 const ippl::Vector<double, 3> delta = r -
origin_m;
155 const ippl::Vector<double, 3>& r)
const {
160 const ippl::Vector<double, 3>& r)
const {
165 const ippl::Vector<double, 3>& r)
const {
182template <
typename ViewType>
185 ippl::Vector<double, 3> ori =
origin_m;
186 Kokkos::parallel_for(
187 "transformBunchTo", nLocal, KOKKOS_LAMBDA(
const size_t i) {
188 ippl::Vector<double, 3> delta = Rview(i) - ori;
193template <
typename ViewType>
196 ippl::Vector<double, 3> ori =
origin_m;
197 Kokkos::parallel_for(
198 "transformBunchFrom", nLocal, KOKKOS_LAMBDA(
const size_t i) {
203template <
typename ViewType>
206 Kokkos::parallel_for(
207 "rotateBunchTo", nLocal,
208 KOKKOS_LAMBDA(
const size_t i) { Pview(i) =
prod_vector(rot, Pview(i)); });
211template <
typename ViewType>
214 Kokkos::parallel_for(
215 "rotateBunchFrom", nLocal,
std::ostream & operator<<(std::ostream &os, const CoordinateSystemTrafo &trafo)
KOKKOS_INLINE_FUNCTION T prod_vector(const matrix_t< Rows, Cols > &rotation, const T &vect)
KOKKOS_INLINE_FUNCTION T prod_vector_transpose(const matrix_t< Rows, Cols > &rotation, const T &vect)
Rigid spatial transform between a parent frame and a local frame.
ippl::Vector< double, 3 > getOrigin() const
matrix3x3_t rotationMatrix_m
Cached rotation matrix for the same parent-to-local mapping.
void rotateBunchFrom(ViewType Pview, size_t nLocal) const
Apply rotateFrom() to a Kokkos view of vectors such as momenta.
ippl::Vector< double, 3 > transformFrom(const ippl::Vector< double, 3 > &r) const
Map a point from the local frame back to the parent frame.
ippl::Vector< double, 3 > rotateFrom(const ippl::Vector< double, 3 > &r) const
Rotate a vector from the local frame back into the parent frame.
matrix3x3_t getRotationMatrix() const
ippl::Vector< double, 3 > rotateTo(const ippl::Vector< double, 3 > &r) const
Rotate a vector from the parent frame into the local frame.
CoordinateSystemTrafo()
Construct the identity transform.
void operator*=(const CoordinateSystemTrafo &right)
void rotateBunchTo(ViewType Pview, size_t nLocal) const
Apply rotateTo() to a Kokkos view of vectors such as momenta.
CoordinateSystemTrafo & operator=(const CoordinateSystemTrafo &right)=default
void transformBunchTo(ViewType Rview, size_t nLocal) const
Apply transformTo() to a Kokkos view of particle positions.
ippl::Vector< double, 3 > transformTo(const ippl::Vector< double, 3 > &r) const
Map a point from the parent frame to the local frame.
void transformBunchFrom(ViewType Rview, size_t nLocal) const
Apply transformFrom() to a Kokkos view of particle positions.
void print(std::ostream &) const
CoordinateSystemTrafo inverted() const
Return the inverse transform.
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.
Quaternion getRotation() const
void invert()
Invert the transform in place.
Quaternion storage and rotation algebra used by OPALX geometry code.
Quaternion conjugate() const
Return the quaternion conjugate .
ippl::Vector< double, 3 > rotate(const ippl::Vector< double, 3 > &) const
Rotate a spatial vector by a unit quaternion.