Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
AxisAngleXother.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// Header file for multiplications of AxisAngle by a rotation
12//
13// Created by: Mark Fischler Tues July 5 2005
14//
15
17
18#include <cmath>
19
25
28
29namespace ROOT {
30
31namespace Math {
32
33
35 // combination with a Rotation3D
36 return operator* ( Quaternion(r) );
37
38}
39
41 // combination with another AxisAngle
42 return operator* ( Quaternion(a) );
43}
44
46 // combination with EulerAngles
47 return operator* ( Quaternion(e) );
48}
49
51 // combination with RotationZYX
52 return operator* ( Quaternion(r) );
53}
54
56 // combination with Quaternion
57 return AxisAngle ( Quaternion(*this) * q );
58}
59
60#ifdef MOVE
61
63 // combination with quaternion (not used)
64 const Scalar s1 = std::sin(fAngle/2);
65 const Scalar au = std::cos(fAngle/2);
66 const Scalar ai = s1 * fAxis.X();
67 const Scalar aj = s1 * fAxis.Y();
68 const Scalar ak = s1 * fAxis.Z();
69 Scalar aqu = au*q.U() - ai*q.I() - aj*q.J() - ak*q.K();
70 Scalar aqi = au*q.I() + ai*q.U() + aj*q.K() - ak*q.J();
71 Scalar aqj = au*q.J() - ai*q.K() + aj*q.U() + ak*q.I();
72 Scalar aqk = au*q.K() + ai*q.J() - aj*q.I() + ak*q.U();
73 Scalar r = std::sqrt(aqi*aqi + aqj*aqj + aqk*aqk);
74 if (r > 1) r = 1;
75 if (aqu < 0) { aqu = - aqu; aqi = - aqi; aqj = - aqj, aqk = - aqk; }
76 const Scalar angle = 2*asin ( r );
77 DisplacementVector3D< Cartesian3D<double> > axis ( aqi, aqj, aqk );
78 if ( r == 0 ) {
79 axis.SetCoordinates(0,0,1);
80 } else {
81 axis /= r;
82 }
83 return AxisAngle ( axis, angle );
84}
85
86#endif
87
89 // combination with RotationX
90
91 const Scalar s1 = std::sin(fAngle/2);
92 const Scalar au = std::cos(fAngle/2);
93 const Scalar ai = s1 * fAxis.X();
94 const Scalar aj = s1 * fAxis.Y();
95 const Scalar ak = s1 * fAxis.Z();
96 Scalar c = rx.CosAngle();
97 if ( c > 1 ) c = 1;
98 if ( c < -1 ) c = -1;
99 Scalar qu = std::sqrt( .5*(1+c) );
100 Scalar qi = std::sqrt( .5*(1-c) );
101 if ( rx.SinAngle() < 0 ) qi = -qi;
102 Scalar aqu = au*qu - ai*qi;
103 Scalar aqi = ai*qu + au*qi;
104 Scalar aqj = aj*qu + ak*qi;
105 Scalar aqk = ak*qu - aj*qi;
106 Scalar r = std::sqrt(aqi*aqi + aqj*aqj + aqk*aqk);
107 if (r > 1) r = 1;
108 if (aqu < 0) { aqu = - aqu; aqi = - aqi; aqj = - aqj, aqk = - aqk; }
109 const Scalar angle = 2*asin ( r );
110 DisplacementVector3D< Cartesian3D<double> > axis ( aqi, aqj, aqk );
111 if ( r == 0 ) {
112 axis.SetCoordinates(0,0,1);
113 } else {
114 axis /= r;
115 }
116 return AxisAngle ( axis, angle );
117}
118
120 // combination with RotationY
121
122 const Scalar s1 = std::sin(fAngle/2);
123 const Scalar au = std::cos(fAngle/2);
124 const Scalar ai = s1 * fAxis.X();
125 const Scalar aj = s1 * fAxis.Y();
126 const Scalar ak = s1 * fAxis.Z();
127 Scalar c = ry.CosAngle();
128 if ( c > 1 ) c = 1;
129 if ( c < -1 ) c = -1;
130 Scalar qu = std::sqrt( .5*(1+c) );
131 Scalar qj = std::sqrt( .5*(1-c) );
132 if ( ry.SinAngle() < 0 ) qj = -qj;
133 Scalar aqu = au*qu - aj*qj;
134 Scalar aqi = ai*qu - ak*qj;
135 Scalar aqj = aj*qu + au*qj;
136 Scalar aqk = ak*qu + ai*qj;
137 Scalar r = std::sqrt(aqi*aqi + aqj*aqj + aqk*aqk);
138 if (r > 1) r = 1;
139 if (aqu < 0) { aqu = - aqu; aqi = - aqi; aqj = - aqj, aqk = - aqk; }
140 const Scalar angle = 2*asin ( r );
141 DisplacementVector3D< Cartesian3D<double> > axis ( aqi, aqj, aqk );
142 if ( r == 0 ) {
143 axis.SetCoordinates(0,0,1);
144 } else {
145 axis /= r;
146 }
147 return AxisAngle ( axis, angle );
148}
149
151 // combination with RotationZ
152
153 const Scalar s1 = std::sin(fAngle/2);
154 const Scalar au = std::cos(fAngle/2);
155 const Scalar ai = s1 * fAxis.X();
156 const Scalar aj = s1 * fAxis.Y();
157 const Scalar ak = s1 * fAxis.Z();
158 Scalar c = rz.CosAngle();
159 if ( c > 1 ) c = 1;
160 if ( c < -1 ) c = -1;
161 Scalar qu = std::sqrt( .5*(1+c) );
162 Scalar qk = std::sqrt( .5*(1-c) );
163 if ( rz.SinAngle() < 0 ) qk = -qk;
164 Scalar aqu = au*qu - ak*qk;
165 Scalar aqi = ai*qu + aj*qk;
166 Scalar aqj = aj*qu - ai*qk;
167 Scalar aqk = ak*qu + au*qk;
168 Scalar r = std::sqrt(aqi*aqi + aqj*aqj + aqk*aqk);
169 if (r > 1) r = 1;
170 if (aqu < 0) { aqu = - aqu; aqi = - aqi; aqj = - aqj, aqk = - aqk; }
171 const Scalar angle = 2*asin ( r );
172 DisplacementVector3D< Cartesian3D<double> > axis ( aqi, aqj, aqk );
173 if ( r == 0 ) {
174 axis.SetCoordinates(0,0,1);
175 } else {
176 axis /= r;
177 }
178 return AxisAngle ( axis, angle );
179}
180
182 return AxisAngle(r) * a; // TODO: improve performance
183}
184
186 return AxisAngle(r) * a; // TODO: improve performance
187}
188
190 return AxisAngle(r) * a; // TODO: improve performance
191}
192
193
194} //namespace Math
195} //namespace ROOT
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define s1(x)
Definition RSha256.hxx:91
#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
Option_t Option_t TPoint TPoint angle
float * q
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
Definition AxisAngle.h:42
AVector operator*(const AVector &v) const
Overload operator * for rotation on a vector.
Definition AxisAngle.h:248
AxisAngle()
Default constructor (axis is z and angle is zero)
Definition AxisAngle.h:57
Class describing a generic displacement vector in 3 dimensions.
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
DisplacementVector3D< CoordSystem, Tag > & SetCoordinates(const Scalar src[])
Set internal data based on a C-style array of 3 Scalar numbers.
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
EulerAngles class describing rotation as three angles (Euler Angles).
Definition EulerAngles.h:45
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
Scalar CosAngle() const
Definition RotationX.h:111
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
Definition RotationX.h:110
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Definition RotationY.h:45
Scalar CosAngle() const
Definition RotationY.h:111
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
Definition RotationY.h:110
Rotation class with the (3D) rotation represented by angles describing first a rotation of an angle p...
Definition RotationZYX.h:63
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Definition RotationZ.h:45
Scalar CosAngle() const
Definition RotationZ.h:111
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
Definition RotationZ.h:110
Namespace for new Math classes and functions.
AxisAngle operator*(RotationX const &r1, AxisAngle const &r2)
Multiplication of an axial rotation by an AxisAngle.
Rotation3D::Scalar Scalar
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...