Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RotationZYX.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 RotationZYX
12//
13// Created by: Lorenzo Moneta, May 23 2007
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
41// ========== Operations =====================
42
43// DisplacementVector3D< Cartesian3D<double> >
44// RotationZYX::
45// operator() (const DisplacementVector3D< Cartesian3D<double> > & v) const
46// {
47// return Rotation3D(*this)(v);
48// }
49
51{
52 // combine with a Rotation3D
53 return RotationZYX(Rotation3D(*this) * r);
54}
55
57{
58 // combine with a AxisAngle
59 return RotationZYX(Quaternion(*this) * Quaternion(a));
60}
61
63{
64 // combine with EulerAngles
65 return RotationZYX(Quaternion(*this) * Quaternion(e));
66}
67
69{
70 // combine with a RotationZYX
71 // return RotationZYX ( Quaternion(*this) * Quaternion(e) );
72 return RotationZYX(Rotation3D(*this) * Rotation3D(e));
73}
75{
76 // combination with a Quaternion
77 return RotationZYX(Quaternion(*this) * q);
78}
79
81{
82 // combine with a RotationX
83 return RotationZYX(Quaternion(*this) * r);
84}
85
87{
88 // combine with a RotationY
89 return RotationZYX(Quaternion(*this) * r);
90}
91
93{
94 // combine with a RotationZ
95 // TODO -- this can be made much faster because it merely adds
96 // the r.Angle() to phi.
97 Scalar newPhi = fPhi + r.Angle();
98 if (newPhi <= -Pi() || newPhi > Pi()) {
99 newPhi = newPhi - math_floor(newPhi / (2 * Pi()) + .5) * 2 * Pi();
100 }
101 return RotationZYX(newPhi, fTheta, fPsi);
102}
103
105{
106 return RotationZYX(r) * e; // TODO: improve performance
107}
108
110{
111 return RotationZYX(r) * e; // TODO: improve performance
112}
113
115{
116 return RotationZYX(r) * e; // TODO: improve performance
117}
118
120{
121 // rectify . The angle theta must be defined between [-PI/2,PI.2]
122 // same as Euler- Angles, just here Theta is shifted by PI/2 with respect to
123 // the theta of the EulerAngles class
124
127 Scalar t = theta2 - math_floor(theta2 / (2 * Pi())) * 2 * Pi();
128 if (t <= Pi()) {
129 theta2 = t;
130 } else {
131 theta2 = 2 * Pi() - t;
132 fPhi = fPhi + Pi();
133 fPsi = fPsi + Pi();
134 }
135 // ftheta is shifted of PI/2 w.r.t theta2
136 fTheta = theta2 - M_PI_2;
137 }
138
139 if (fPhi <= -Pi() || fPhi > Pi()) {
140 fPhi = fPhi - math_floor(fPhi / (2 * Pi()) + .5) * 2 * Pi();
141 }
142
143 if (fPsi <= -Pi() || fPsi > Pi()) {
144 fPsi = fPsi - math_floor(fPsi / (2 * Pi()) + .5) * 2 * Pi();
145 }
146
147} // Rectify()
148
150{
151 // invert this rotation.
152 // use Rotation3D. TO Do :have algorithm to invert it directly
153 Rotation3D r(*this);
154 // Quaternion r(*this);
155 r.Invert();
156 *this = r;
157}
158
159#if !defined(ROOT_MATH_SYCL) && !defined(ROOT_MATH_CUDA)
160
161// ========== I/O =====================
162
163std::ostream &operator<<(std::ostream &os, const RotationZYX &e)
164{
165 // TODO - this will need changing for machine-readable issues
166 // and even the human readable form may need formatting improvements
167 os << "\n{phi(Z angle): " << e.Phi() << " theta(Y angle): " << e.Theta() << " psi(X angle): " << e.Psi()
168 << "}\n";
169 return os;
170}
171#endif
172
173} // namespace ROOT_MATH_ARCH
174} // namespace ROOT
#define M_PI_2
Definition Math.h:41
#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
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 with the (3D) rotation represented by angles describing first a rotation of an angle p...
Definition RotationZYX.h:64
AVector operator*(const AVector &v) const
Overload operator * for rotation on a vector.
RotationZYX()
Default constructor.
Definition RotationZYX.h:74
void Invert()
Invert a rotation in place.
void Rectify()
Re-adjust components place angles in canonical ranges.
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.