Logo ROOT   6.19/01
Reference Guide
QuaternionXaxial.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 quaternion times other non-axial rotations.
12 // Decoupled from main Quaternion implementations.
13 //
14 // Created by: Mark Fischler Tues July 19, 2005
15 //
16 // Last update: $Id$
17 //
19 
20 namespace ROOT {
21 
22 namespace Math {
23 
24 
25 // Although the same technique would work with axial rotations,
26 // we know that two of the four quaternion components will be zero,
27 // and we exploit that knowledge:
28 
30  // combination with a RotationX
31  Quaternion q(rx);
32  return Quaternion (
33  U()*q.U() - I()*q.I()
34  , I()*q.U() + U()*q.I()
35  , J()*q.U() + K()*q.I()
36  , K()*q.U() - J()*q.I()
37  );
38 }
39 
41  // combination with a RotationY
42  Quaternion q(ry);
43  return Quaternion (
44  U()*q.U() - J()*q.J()
45  , I()*q.U() - K()*q.J()
46  , J()*q.U() + U()*q.J()
47  , K()*q.U() + I()*q.J()
48  );
49 }
50 
52  // combination with a RotationZ
53  Quaternion q(rz);
54  return Quaternion (
55  U()*q.U() - K()*q.K()
56  , I()*q.U() + J()*q.K()
57  , J()*q.U() - I()*q.K()
58  , K()*q.U() + U()*q.K()
59  );
60 }
61 
63 operator * ( RotationX const & r, Quaternion const & q ) {
64  return Quaternion(r) * q; // TODO: improve performance
65 }
66 
67 Quaternion
68 operator * ( RotationY const & r, Quaternion const & q ) {
69  return Quaternion(r) * q; // TODO: improve performance
70 }
71 
72 Quaternion
73 operator * ( RotationZ const & r, Quaternion const & q ) {
74  return Quaternion(r) * q; // TODO: improve performance
75 }
76 
77 
78 } //namespace Math
79 } //namespace ROOT
Scalar I() const
Definition: Quaternion.h:172
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Definition: RotationZ.h:43
Scalar J() const
Definition: Quaternion.h:173
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Definition: Quaternion.h:47
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Definition: RotationY.h:43
Scalar U() const
Access to the four quaternion components: U() is the coefficient of the identity Pauli matrix...
Definition: Quaternion.h:171
ROOT::R::TRInterface & r
Definition: Object.C:4
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Definition: RotationX.h:43
Namespace for new Math classes and functions.
Scalar K() const
Definition: Quaternion.h:174
float * q
Definition: THbookFile.cxx:87
Quaternion()
Default constructor (identity rotation)
Definition: Quaternion.h:58
AVector operator*(const AVector &v) const
Overload operator * for rotation on a vector.
Definition: Quaternion.h:246
AxisAngle operator*(RotationX const &r1, AxisAngle const &r2)
Multiplication of an axial rotation by an AxisAngle.