OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Quaternion.cpp File Reference
#include "Algorithms/Quaternion.hpp"
#include <cmath>
#include <iostream>
#include "Algorithms/Matrix.h"
#include "OPALTypes.h"
#include "Physics/Physics.h"
#include "Utilities/GeneralOpalException.h"
Include dependency graph for Quaternion.cpp:

Go to the source code of this file.

Functions

Quaternion getQuaternion (ippl::Vector< double, 3 > u, ippl::Vector< double, 3 > ref)
 Return a unit quaternion that rotates vec onto reference.
 

Function Documentation

◆ getQuaternion()

Quaternion getQuaternion ( ippl::Vector< double, 3 >  vec,
ippl::Vector< double, 3 >  reference 
)

Return a unit quaternion that rotates vec onto reference.

Both input vectors are normalized internally. For the generic case, the quaternion is built from the rotation axis \(\mathbf{a} \propto \mathbf{vec} \times \mathbf{reference}\) and the half-angle formula. For antiparallel vectors the current implementation chooses an arbitrary orthogonal axis, so the 180-degree rotation is valid but not deterministic.

Definition at line 35 of file Quaternion.cpp.

References cross(), dot(), and Physics::pi.

Referenced by ParticleContainer< T, Dim >::applyFractionalStep(), ParallelTracker::computeSpaceChargeFields(), Monitor::driftToCorrectPositionAndSave(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and ParticleContainer< T, Dim >::updateRefToLabCSTrafo().

Here is the call graph for this function: