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