https://mooseframework.inl.gov
Public Member Functions | Public Attributes | List of all members
EulerAngles Class Reference

Euler angle triplet. More...

#include <EulerAngles.h>

Public Member Functions

 EulerAngles ()
 
 EulerAngles (const Eigen::Quaternion< Real > &q)
 
 EulerAngles (const Real &v0, const Real &v1, const Real &v2)
 
 operator RealVectorValue () const
 
void random ()
 
void random (MooseRandom &random)
 
Eigen::Quaternion< RealtoQuaternion ()
 

Public Attributes

Real phi1
 
Real Phi
 
Real phi2
 

Detailed Description

Euler angle triplet.

Definition at line 24 of file EulerAngles.h.

Constructor & Destructor Documentation

◆ EulerAngles() [1/3]

EulerAngles::EulerAngles ( )

Definition at line 14 of file EulerAngles.C.

15 {
16  phi1 = 0.0;
17  Phi = 0.0;
18  phi2 = 0.0;
19 }

◆ EulerAngles() [2/3]

EulerAngles::EulerAngles ( const Eigen::Quaternion< Real > &  q)

Definition at line 21 of file EulerAngles.C.

22 {
23  phi1 = std::atan2((q.x() * q.z() + q.w() * q.y()), -(-q.w() * q.x() + q.y() * q.z())) *
24  (180.0 / libMesh::pi);
25 
26  // avoid NAN value from sqrt(val) while computing Phi
27  auto val = 1.0 - std::pow(q.w() * q.w() - q.x() * q.x() - q.y() * q.y() + q.z() * q.z(), 2.0);
28  if (val < 0.0 && !MooseUtils::absoluteFuzzyEqual(val, 0.0))
29  mooseError("Euler angle conversion is not successful due to invalid quaternion value.");
30 
31  Phi = std::atan2(std::sqrt(std::abs(val)),
32  q.w() * q.w() - q.x() * q.x() - q.y() * q.y() + q.z() * q.z()) *
33  (180.0 / libMesh::pi);
34  phi2 = std::atan2((q.x() * q.z() - q.w() * q.y()), (q.w() * q.x() + q.y() * q.z())) *
35  (180.0 / libMesh::pi);
36 
37  // Following checks and updates are done only to comply with bunge euler angle definitions, 0.0
38  // <= phi1/phi2 <= 360.0
39  if (phi1 < 0.0)
40  phi1 += 360.0;
41  if (phi2 < 0.0)
42  phi2 += 360.0;
43  if (Phi < 0.0)
44  mooseError("Euler angle out of range.");
45 }
void mooseError(Args &&... args)
MooseUnits pow(const MooseUnits &, int)
const Real pi

◆ EulerAngles() [3/3]

EulerAngles::EulerAngles ( const Real v0,
const Real v1,
const Real v2 
)

Definition at line 47 of file EulerAngles.C.

48 {
49  phi1 = v0;
50  Phi = v1;
51  phi2 = v2;
52 }

Member Function Documentation

◆ operator RealVectorValue()

EulerAngles::operator RealVectorValue ( ) const
inline

Definition at line 36 of file EulerAngles.h.

◆ random() [1/2]

void EulerAngles::random ( )

Definition at line 84 of file EulerAngles.C.

Referenced by RandomEulerAngleProvider::initialize(), GrainTrackerElasticity::newGrain(), and random().

85 {
86  phi1 = MooseRandom::rand() * 360.0;
87  Phi = std::acos(1.0 - 2.0 * MooseRandom::rand()) / libMesh::pi * 180.0;
88  phi2 = MooseRandom::rand() * 360;
89 }
static Real rand()
const Real pi

◆ random() [2/2]

void EulerAngles::random ( MooseRandom random)

Definition at line 92 of file EulerAngles.C.

93 {
94  phi1 = random.rand(0) * 360.0;
95  Phi = std::acos(1.0 - 2.0 * random.rand(0)) / libMesh::pi * 180.0;
96  phi2 = random.rand(0) * 360;
97 }
void random()
Definition: EulerAngles.C:84
const Real pi

◆ toQuaternion()

Eigen::Quaternion< Real > EulerAngles::toQuaternion ( )

"NASA Mission Planning and Analysis Division. "Euler Angles, Quaternions, and Transformation Matrices". NASA.

Definition at line 55 of file EulerAngles.C.

Referenced by EBSDReader::readFile().

56 {
57  Eigen::Quaternion<Real> q;
58 
59  Real cPhi1PlusPhi2, cphi, cPhi1MinusPhi2;
60  Real sPhi1PlusPhi2, sphi, sPhi1MinusPhi2;
61 
67  cPhi1PlusPhi2 = std::cos((phi1 * libMesh::pi / 180.0 + phi2 * libMesh::pi / 180.0) / 2.0);
68  cphi = std::cos(Phi * libMesh::pi / 360.0);
69  cPhi1MinusPhi2 = std::cos((phi1 * libMesh::pi / 180.0 - phi2 * libMesh::pi / 180.0) / 2.0);
70 
71  sPhi1PlusPhi2 = std::sin((phi1 * libMesh::pi / 180.0 + phi2 * libMesh::pi / 180.0) / 2.0);
72  sphi = std::sin(Phi * libMesh::pi / 360.0);
73  sPhi1MinusPhi2 = std::sin((phi1 * libMesh::pi / 180.0 - phi2 * libMesh::pi / 180.0) / 2.0);
74 
75  q.w() = cphi * cPhi1PlusPhi2;
76  q.x() = sphi * cPhi1MinusPhi2;
77  q.y() = sphi * sPhi1MinusPhi2;
78  q.z() = cphi * sPhi1PlusPhi2;
79 
80  return q;
81 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real pi

Member Data Documentation

◆ Phi

Real EulerAngles::Phi

◆ phi1

Real EulerAngles::phi1

◆ phi2

Real EulerAngles::phi2

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