Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
EulerAngles.cxx
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Authors: W. Brown, M. Fischler, L. Moneta 2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 , LCG ROOT FNAL MathLib Team *
7 * *
8 * *
9 **********************************************************************/
10
11// Implementation file for rotation in 3 dimensions, represented by EulerAngles
12//
13// Created by: Mark Fischler Thurs June 9 2005
14//
15// Last update: $Id$
16//
18
19#include <cmath>
20
28
30
32
34
35namespace ROOT {
36
37namespace ROOT_MATH_ARCH {
38
39// ========== Constructors and Assignment =====================
40
42{
43 // rectify
45 Scalar t = fTheta - math_floor(fTheta / (2 * Pi())) * 2 * Pi();
46 if (t <= Pi()) {
47 fTheta = t;
48 } else {
49 fTheta = 2 * Pi() - t;
50 fPhi = fPhi + Pi();
51 fPsi = fPsi + Pi();
52 }
53 }
54
55 if (fPhi <= -Pi() || fPhi > Pi()) {
56 fPhi = fPhi - math_floor(fPhi / (2 * Pi()) + .5) * 2 * Pi();
57 }
58
59 if (fPsi <= -Pi() || fPsi > Pi()) {
60 fPsi = fPsi - math_floor(fPsi / (2 * Pi()) + .5) * 2 * Pi();
61 }
62
63} // Rectify()
64
65// ========== Operations =====================
66
67// DisplacementVector3D< Cartesian3D<double> >
68// EulerAngles::
69// operator() (const DisplacementVector3D< Cartesian3D<double> > & v) const
70// {
71// return Rotation3D(*this)(v);
72// }
73
75{
76 // combine with a Rotation3D
77 return EulerAngles(Rotation3D(*this) * r);
78}
79
81{
82 // combine with a AxisAngle
83 return EulerAngles(Quaternion(*this) * Quaternion(a));
84}
85
87{
88 // combine with a EulerAngles
89 return EulerAngles(Quaternion(*this) * Quaternion(e));
90}
92{
93 // combination with a Quaternion
94 return EulerAngles(Quaternion(*this) * q);
95}
96
98{
99 // combine with a RotationX
100 return EulerAngles(Quaternion(*this) * r);
101}
102
104{
105 // combine with a RotationY
106 return EulerAngles(Quaternion(*this) * r);
107}
108
110{
111 // combine with a RotationZ
112 // TODO -- this can be made much faster because it merely adds
113 // the r.Angle() to phi.
114 Scalar newPhi = fPhi + r.Angle();
115 if (newPhi <= -Pi() || newPhi > Pi()) {
116 newPhi = newPhi - math_floor(newPhi / (2 * Pi()) + .5) * 2 * Pi();
117 }
118 return EulerAngles(newPhi, fTheta, fPsi);
119}
120
122{
123 return EulerAngles(r) * e; // TODO: improve performance
124}
125
127{
128 return EulerAngles(r) * e; // TODO: improve performance
129}
130
132{
133 return EulerAngles(r) * e; // TODO: improve performance
134}
135
136#if !defined(ROOT_MATH_SYCL) && !defined(ROOT_MATH_CUDA)
137// ========== I/O =====================
138
139std::ostream &operator<<(std::ostream &os, const EulerAngles &e)
140{
141 // TODO - this will need changing for machine-readable issues
142 // and even the human readable form may need formatting improvements
143 os << "\n{phi: " << e.Phi() << " theta: " << e.Theta() << " psi: " << e.Psi() << "}\n";
144 return os;
145}
146#endif
147
148} // namespace ROOT_MATH_ARCH
149} // namespace ROOT
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
float * q
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
Definition AxisAngle.h:46
EulerAngles class describing rotation as three angles (Euler Angles).
Definition EulerAngles.h:50
AVector operator*(const AVector &v) const
Overload operator * for rotation on a vector.
EulerAngles()
Default constructor.
Definition EulerAngles.h:58
void Rectify()
Re-adjust components place angles in canonical ranges.
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Definition Quaternion.h:52
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Definition Rotation3D.h:71
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Definition RotationX.h:45
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Definition RotationY.h:45
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Definition RotationZ.h:45
Scalar math_floor(Scalar x)
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition AxisAngle.cxx:98
AxisAngle operator*(RotationX const &r1, AxisAngle const &r2)
Multiplication of an axial rotation by an AxisAngle.