www.mooseframework.org
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)
 
 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/2]

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/2]

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  Phi = std::atan2(
26  std::sqrt(1 -
27  std::pow(q.w() * q.w() - q.x() * q.x() - q.y() * q.y() + q.z() * q.z(), 2.0)),
28  q.w() * q.w() - q.x() * q.x() - q.y() * q.y() + q.z() * q.z()) *
29  (180.0 / libMesh::pi);
30  phi2 = std::atan2((q.x() * q.z() - q.w() * q.y()), (q.w() * q.x() + q.y() * q.z())) *
31  (180.0 / libMesh::pi);
32 
33  // Following checks and updates are done only to comply with bunge euler angle definitions, 0.0
34  // <= phi1/phi2 <= 360.0
35  if (phi1 < 0.0)
36  phi1 += 360.0;
37  if (phi2 < 0.0)
38  phi2 += 360.0;
39  if (Phi < 0.0)
40  mooseError("Euler angle out of range.");
41 }
void mooseError(Args &&... args)
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
MooseUnits pow(const MooseUnits &, int)
const Real pi

Member Function Documentation

◆ operator RealVectorValue()

EulerAngles::operator RealVectorValue ( ) const
inline

Definition at line 34 of file EulerAngles.h.

◆ random() [1/2]

void EulerAngles::random ( )

Definition at line 73 of file EulerAngles.C.

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

74 {
75  phi1 = MooseRandom::rand() * 360.0;
76  Phi = std::acos(1.0 - 2.0 * MooseRandom::rand()) / libMesh::pi * 180.0;
77  phi2 = MooseRandom::rand() * 360;
78 }
static Real rand()
const Real pi

◆ random() [2/2]

void EulerAngles::random ( MooseRandom random)

Definition at line 81 of file EulerAngles.C.

82 {
83  phi1 = random.rand(0) * 360.0;
84  Phi = std::acos(1.0 - 2.0 * random.rand(0)) / libMesh::pi * 180.0;
85  phi2 = random.rand(0) * 360;
86 }
void random()
Definition: EulerAngles.C:73
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 44 of file EulerAngles.C.

Referenced by EBSDReader::readFile().

45 {
46  Eigen::Quaternion<Real> q;
47 
48  Real cPhi1PlusPhi2, cphi, cPhi1MinusPhi2;
49  Real sPhi1PlusPhi2, sphi, sPhi1MinusPhi2;
50 
56  cPhi1PlusPhi2 = std::cos((phi1 * libMesh::pi / 180.0 + phi2 * libMesh::pi / 180.0) / 2.0);
57  cphi = std::cos(Phi * libMesh::pi / 360.0);
58  cPhi1MinusPhi2 = std::cos((phi1 * libMesh::pi / 180.0 - phi2 * libMesh::pi / 180.0) / 2.0);
59 
60  sPhi1PlusPhi2 = std::sin((phi1 * libMesh::pi / 180.0 + phi2 * libMesh::pi / 180.0) / 2.0);
61  sphi = std::sin(Phi * libMesh::pi / 360.0);
62  sPhi1MinusPhi2 = std::sin((phi1 * libMesh::pi / 180.0 - phi2 * libMesh::pi / 180.0) / 2.0);
63 
64  q.w() = cphi * cPhi1PlusPhi2;
65  q.x() = sphi * cPhi1MinusPhi2;
66  q.y() = sphi * sPhi1MinusPhi2;
67  q.z() = cphi * sPhi1PlusPhi2;
68 
69  return q;
70 }
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: