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
31namespace ROOT {
32
33namespace 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
120EulerAngles
121operator * ( RotationZ const & r, EulerAngles const & e ) {
122 return EulerAngles(r) * e; // TODO: improve performance
123}
124
125// ========== I/O =====================
126
127std::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 formatting 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
#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:42
EulerAngles class describing rotation as three angles (Euler Angles).
Definition EulerAngles.h:45
AVector operator*(const AVector &v) const
Overload operator * for rotation on a vector.
void Rectify()
Re-adjust components place angles in canonical ranges.
constexpr EulerAngles()
Default constructor.
Definition EulerAngles.h:54
Scalar Phi() const
Return Phi Euler angle.
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Definition Quaternion.h:49
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Definition Rotation3D.h:67
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
Namespace for new Math classes and functions.
AxisAngle operator*(RotationX const &r1, AxisAngle const &r2)
Multiplication of an axial rotation by an AxisAngle.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...