Logo ROOT   master
Reference Guide
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 
31 namespace ROOT {
32 
33 namespace Math {
34 
35 // ========== Constructors and Assignment =====================
36 
38 {
39  // rectify
40  if ( fTheta < 0 || fTheta > Pi() ) {
41  Scalar t = fTheta - std::floor( fTheta/(2*Pi()) ) * 2*Pi();
42  if ( t <= Pi() ) {
43  fTheta = t;
44  } else {
45  fTheta = 2*Pi() - t;
46  fPhi = fPhi + Pi();
47  fPsi = fPsi + Pi();
48  }
49  }
50 
51  if ( fPhi <= -Pi()|| fPhi > Pi() ) {
52  fPhi = fPhi - std::floor( fPhi/(2*Pi()) +.5 ) * 2*Pi();
53  }
54 
55  if ( fPsi <= -Pi()|| fPsi > Pi() ) {
56  fPsi = fPsi - std::floor( fPsi/(2*Pi()) +.5 ) * 2*Pi();
57  }
58 
59 } // Rectify()
60 
61 
62 // ========== Operations =====================
63 
64 // DisplacementVector3D< Cartesian3D<double> >
65 // EulerAngles::
66 // operator() (const DisplacementVector3D< Cartesian3D<double> > & v) const
67 // {
68 // return Rotation3D(*this)(v);
69 // }
70 
71 
73  // combine with a Rotation3D
74  return EulerAngles ( Rotation3D(*this) * r );
75 }
76 
78  // combine with a AxisAngle
79  return EulerAngles ( Quaternion(*this) * Quaternion(a) );
80 }
81 
83  // combine with a EulerAngles
84  return EulerAngles ( Quaternion(*this) * Quaternion(e) );
85 }
87  // combination with a Quaternion
88  return EulerAngles ( Quaternion(*this) * q );
89 }
90 
92  // combine with a RotationX
93  return EulerAngles ( Quaternion(*this) * r );
94 }
95 
97  // combine with a RotationY
98  return EulerAngles ( Quaternion(*this) * r );
99 }
100 
102  // combine with a RotationZ
103  // TODO -- this can be made much faster because it merely adds
104  // the r.Angle() to phi.
105  Scalar newPhi = fPhi + r.Angle();
106  if ( newPhi <= -Pi()|| newPhi > Pi() ) {
107  newPhi = newPhi - std::floor( newPhi/(2*Pi()) +.5 ) * 2*Pi();
108  }
109  return EulerAngles ( newPhi, fTheta, fPsi );
110 }
111 
113  return EulerAngles(r) * e; // TODO: improve performance
114 }
115 
117  return EulerAngles(r) * e; // TODO: improve performance
118 }
119 
120 EulerAngles
121 operator * ( RotationZ const & r, EulerAngles const & e ) {
122  return EulerAngles(r) * e; // TODO: improve performance
123 }
124 
125 // ========== I/O =====================
126 
127 std::ostream & operator<< (std::ostream & os, const EulerAngles & e) {
128  // TODO - this will need changing for machine-readable issues
129  // and even the human readable form may need formatiing improvements
130  os << "\n{phi: " << e.Phi() << " theta: " << e.Theta()
131  << " psi: " << e.Psi() << "}\n";
132  return os;
133 }
134 
135 
136 } //namespace Math
137 } //namespace ROOT
Returns the available number of logical cores.
Definition: StringConv.hxx:21
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Definition: RotationZ.h:43
void Rectify()
Re-adjust components place angles in canonical ranges.
Definition: EulerAngles.cxx:37
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Definition: Quaternion.h:47
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition: AxisAngle.cxx:91
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
Definition: AxisAngle.h:41
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Definition: RotationY.h:43
ROOT::R::TRInterface & r
Definition: Object.C:4
auto * a
Definition: textangle.C:12
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Definition: RotationX.h:43
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Definition: Rotation3D.h:65
double floor(double)
EulerAngles()
Default constructor.
Definition: EulerAngles.h:52
EulerAngles class describing rotation as three angles (Euler Angles).
Definition: EulerAngles.h:43
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
Namespace for new Math classes and functions.
AVector operator*(const AVector &v) const
Overload operator * for rotation on a vector.
Definition: EulerAngles.h:281
float * q
Definition: THbookFile.cxx:87
AxisAngle operator*(RotationX const &r1, AxisAngle const &r2)
Multiplication of an axial rotation by an AxisAngle.
static double Pi()
Definition: EulerAngles.h:346