Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
29 Quaternion Quaternion::operator * (const RotationX & rx) const {
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 
40 Quaternion Quaternion::operator * (const RotationY & ry) const {
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 
51 Quaternion Quaternion::operator * (const RotationZ & rz) const {
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 
62 Quaternion
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