OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
CoordinateSystemTrafo Class Reference

Rigid spatial transform between a parent frame and a local frame. More...

#include <CoordinateSystemTrafo.h>

Collaboration diagram for CoordinateSystemTrafo:
Collaboration graph

Public Member Functions

 CoordinateSystemTrafo ()
 Construct the identity transform.
 
 CoordinateSystemTrafo (const CoordinateSystemTrafo &right)
 
 CoordinateSystemTrafo (const ippl::Vector< double, 3 > &origin, const Quaternion &orientation)
 Construct a parent-to-local transform.
 
void invert ()
 Invert the transform in place.
 
CoordinateSystemTrafo inverted () const
 Return the inverse transform.
 
ippl::Vector< double, 3 > transformTo (const ippl::Vector< double, 3 > &r) const
 Map a point from the parent frame to the local frame.
 
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 > rotateTo (const ippl::Vector< double, 3 > &r) const
 Rotate a vector from the parent frame into the local 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.
 
template<typename ViewType >
void transformBunchTo (ViewType Rview, size_t nLocal) const
 Apply transformTo() to a Kokkos view of particle positions.
 
template<typename ViewType >
void transformBunchFrom (ViewType Rview, size_t nLocal) const
 Apply transformFrom() to a Kokkos view of particle positions.
 
template<typename ViewType >
void rotateBunchTo (ViewType Pview, size_t nLocal) const
 Apply rotateTo() to a Kokkos view of vectors such as momenta.
 
template<typename ViewType >
void rotateBunchFrom (ViewType Pview, size_t nLocal) const
 Apply rotateFrom() to a Kokkos view of vectors such as momenta.
 
CoordinateSystemTrafooperator= (const CoordinateSystemTrafo &right)=default
 
CoordinateSystemTrafo operator* (const CoordinateSystemTrafo &right) const
 Compose two transforms.
 
void operator*= (const CoordinateSystemTrafo &right)
 
ippl::Vector< double, 3 > getOrigin () const
 
Quaternion getRotation () const
 
matrix3x3_t getRotationMatrix () const
 
void print (std::ostream &) const
 

Private Attributes

ippl::Vector< double, 3 > origin_m
 Local origin expressed in the parent frame.
 
Quaternion orientation_m
 Quaternion whose rotation maps parent-frame vectors into local-frame vectors.
 
matrix3x3_t rotationMatrix_m
 Cached rotation matrix for the same parent-to-local mapping.
 

Detailed Description

Rigid spatial transform between a parent frame and a local frame.

OPALX uses this class as a rigid transform with translation and rotation. The stored origin \(\mathbf{o}\) is the location of the local origin expressed in the parent frame. The stored rotation \(R\) maps parent-frame vectors into local-frame vectors.

For a point \(\mathbf{r}\) in the parent frame, the local coordinates are computed as

\[ \mathbf{r}_{\mathrm{local}} = R \left(\mathbf{r}_{\mathrm{parent}} - \mathbf{o}\right). \]

The inverse mapping is

\[ \mathbf{r}_{\mathrm{parent}} = R^T \mathbf{r}_{\mathrm{local}} + \mathbf{o}. \]

The same convention is used for pure vector rotations without translation:

\[ \mathbf{v}_{\mathrm{local}} = R \mathbf{v}_{\mathrm{parent}}, \qquad \mathbf{v}_{\mathrm{parent}} = R^T \mathbf{v}_{\mathrm{local}}. \]

Composition follows function composition of transformTo():

\[ (A * B)(\mathbf{r}) = A(B(\mathbf{r})). \]

In other words, A * B applies B first and then A.

Definition at line 40 of file CoordinateSystemTrafo.h.

Constructor & Destructor Documentation

◆ CoordinateSystemTrafo() [1/3]

CoordinateSystemTrafo::CoordinateSystemTrafo ( )

Construct the identity transform.

Definition at line 3 of file CoordinateSystemTrafo.cpp.

References rotationMatrix_m.

◆ CoordinateSystemTrafo() [2/3]

CoordinateSystemTrafo::CoordinateSystemTrafo ( const CoordinateSystemTrafo right)

Definition at line 18 of file CoordinateSystemTrafo.cpp.

◆ CoordinateSystemTrafo() [3/3]

CoordinateSystemTrafo::CoordinateSystemTrafo ( const ippl::Vector< double, 3 > &  origin,
const Quaternion orientation 
)

Construct a parent-to-local transform.

Parameters
originPosition of the local origin in parent coordinates.
orientationUnit quaternion whose rotation matrix maps parent-frame vectors into local-frame vectors.

Definition at line 23 of file CoordinateSystemTrafo.cpp.

Member Function Documentation

◆ getOrigin()

◆ getRotation()

Quaternion CoordinateSystemTrafo::getRotation ( ) const
inline

◆ getRotationMatrix()

matrix3x3_t CoordinateSystemTrafo::getRotationMatrix ( ) const
inline

◆ invert()

void CoordinateSystemTrafo::invert ( )

Invert the transform in place.

Definition at line 29 of file CoordinateSystemTrafo.cpp.

References Quaternion::conjugate(), get_transpose(), orientation_m, origin_m, Quaternion::rotate(), and rotationMatrix_m.

Referenced by inverted(), and TEST_F().

Here is the call graph for this function:

◆ inverted()

◆ operator*()

CoordinateSystemTrafo CoordinateSystemTrafo::operator* ( const CoordinateSystemTrafo right) const

Compose two transforms.

For a point \(\mathbf{r}\) in the parent frame,

\[ (A * B).transformTo(\mathbf{r}) = A.transformTo(B.transformTo(\mathbf{r})). \]

Definition at line 35 of file CoordinateSystemTrafo.cpp.

◆ operator*=()

void CoordinateSystemTrafo::operator*= ( const CoordinateSystemTrafo right)

◆ operator=()

CoordinateSystemTrafo & CoordinateSystemTrafo::operator= ( const CoordinateSystemTrafo right)
default

◆ print()

void CoordinateSystemTrafo::print ( std::ostream &  os) const
inline

Definition at line 142 of file CoordinateSystemTrafo.h.

References Quaternion::conjugate(), orientation_m, origin_m, and Quaternion::rotate().

Referenced by operator<<(), and operator<<().

Here is the call graph for this function:

◆ rotateBunchFrom()

template<typename ViewType >
void CoordinateSystemTrafo::rotateBunchFrom ( ViewType  Pview,
size_t  nLocal 
) const
inline

Apply rotateFrom() to a Kokkos view of vectors such as momenta.

Definition at line 212 of file CoordinateSystemTrafo.h.

References prod_vector_transpose(), and rotationMatrix_m.

Here is the call graph for this function:

◆ rotateBunchTo()

template<typename ViewType >
void CoordinateSystemTrafo::rotateBunchTo ( ViewType  Pview,
size_t  nLocal 
) const
inline

Apply rotateTo() to a Kokkos view of vectors such as momenta.

Definition at line 204 of file CoordinateSystemTrafo.h.

References prod_vector(), and rotationMatrix_m.

Referenced by ParallelTracker::computeSpaceChargeFields(), and ParticleContainer< T, Dim >::transformBunch().

Here is the call graph for this function:

◆ rotateFrom()

ippl::Vector< double, 3 > CoordinateSystemTrafo::rotateFrom ( const ippl::Vector< double, 3 > &  r) const
inline

◆ rotateTo()

ippl::Vector< double, 3 > CoordinateSystemTrafo::rotateTo ( const ippl::Vector< double, 3 > &  r) const
inline

Rotate a vector from the parent frame into the local frame.

Definition at line 159 of file CoordinateSystemTrafo.h.

References prod_vector(), and rotationMatrix_m.

Referenced by MeshGenerator::add(), Monitor::driftToCorrectPositionAndSave(), ParallelTracker::execute(), OpalBeamline::rotateTo(), OpalBeamline::rotateToLocalCS(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and ParallelTracker::updateReferenceParticles().

Here is the call graph for this function:

◆ transformBunchFrom()

template<typename ViewType >
void CoordinateSystemTrafo::transformBunchFrom ( ViewType  Rview,
size_t  nLocal 
) const
inline

Apply transformFrom() to a Kokkos view of particle positions.

Definition at line 194 of file CoordinateSystemTrafo.h.

References origin_m, prod_vector_transpose(), and rotationMatrix_m.

Here is the call graph for this function:

◆ transformBunchTo()

template<typename ViewType >
void CoordinateSystemTrafo::transformBunchTo ( ViewType  Rview,
size_t  nLocal 
) const
inline

Apply transformTo() to a Kokkos view of particle positions.

The operation is pointwise and uses the same rigid-transform convention as transformTo().

Definition at line 183 of file CoordinateSystemTrafo.h.

References origin_m, prod_vector(), and rotationMatrix_m.

Referenced by ParallelTracker::computeSpaceChargeFields(), and ParticleContainer< T, Dim >::transformBunch().

Here is the call graph for this function:

◆ transformFrom()

ippl::Vector< double, 3 > CoordinateSystemTrafo::transformFrom ( const ippl::Vector< double, 3 > &  r) const
inline

◆ transformTo()

ippl::Vector< double, 3 > CoordinateSystemTrafo::transformTo ( const ippl::Vector< double, 3 > &  r) const
inline

Member Data Documentation

◆ orientation_m

Quaternion CoordinateSystemTrafo::orientation_m
private

Quaternion whose rotation maps parent-frame vectors into local-frame vectors.

Definition at line 125 of file CoordinateSystemTrafo.h.

Referenced by getRotation(), invert(), operator*=(), and print().

◆ origin_m

ippl::Vector<double, 3> CoordinateSystemTrafo::origin_m
private

Local origin expressed in the parent frame.

Definition at line 122 of file CoordinateSystemTrafo.h.

Referenced by getOrigin(), invert(), operator*=(), print(), transformBunchFrom(), transformBunchTo(), transformFrom(), and transformTo().

◆ rotationMatrix_m

matrix3x3_t CoordinateSystemTrafo::rotationMatrix_m
private

Cached rotation matrix for the same parent-to-local mapping.

Definition at line 128 of file CoordinateSystemTrafo.h.

Referenced by CoordinateSystemTrafo(), getRotationMatrix(), invert(), operator*=(), rotateBunchFrom(), rotateBunchTo(), rotateFrom(), rotateTo(), transformBunchFrom(), transformBunchTo(), and transformTo().


The documentation for this class was generated from the following files: