OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Rotation3D.h
Go to the documentation of this file.
1 #ifndef CLASSIC_Rotation3D_HH
2 #define CLASSIC_Rotation3D_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Rotation3D.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Rotation3D
13 //
14 // ------------------------------------------------------------------------
15 // Class category: BeamlineGeometry
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:34 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
25 
26 
27 // Class Rotation3D
28 // -----------------------------------------------------------------------
30 // There are two possible external representations:
31 // [DL]
32 // [DT]Matrix3D R[DD]
33 // The matrix R is an element of SO(3). Its column vectors define the
34 // unit vectors of the rotated coordinate system, expressed in the
35 // original system. This representation is used internally and can only
36 // be read from a Rotation3D object. To build such an object, use the
37 // other representation.
38 // [DT]Vector3D V[DD]
39 // The direction of V defines the axis of rotation, and its length the
40 // sine of half the rotation angle. A zero vector represents the identity.
41 // [/DL]
42 // The copy constructor, destructor, and assignment operator generated
43 // by the compiler perform the correct operation. For speed reasons they
44 // are not implemented.
45 
46 class Rotation3D {
47 
48 public:
49 
51  // Constructs identity.
52  Rotation3D();
53 
55  // Use axis vector (vx,vy,vz).
56  Rotation3D(double vx, double vy, double vz);
57 
58  bool operator==(const Rotation3D &) const;
59  bool operator!=(const Rotation3D &) const;
60 
62  Rotation3D &operator*=(const Rotation3D &rhs);
63 
65  Rotation3D operator*(const Rotation3D &rhs) const;
66 
68  // Return vector [b]rhs[/b] rotated by the rotation [b]this[/b].
69  Vector3D operator*(const Vector3D &rhs) const;
70 
72  // Return element (i,k) of the orthogonal matrix.
73  double operator()(int i, int k) const;
74 
76  // Return the axis vector.
77  Vector3D getAxis() const;
78 
80  // Return the axis vector in (vx,vy,vz).
81  void getAxis(double &vx, double &vy, double &vz) const;
82 
84  Rotation3D inverse() const;
85 
87  bool isIdentity() const;
88 
90  // Return true, if [b]this[/b] is a pure x-rotation.
91  bool isPureXRotation() const;
92 
94  // Return true, if [b]this[/b] is a pure y-rotation.
95  bool isPureYRotation() const;
96 
98  // Return true, if [b]this[/b] is a pure z-rotation.
99  bool isPureZRotation() const;
100 
102  static Rotation3D Identity();
103 
105  // Construct pure rotation around x-axis.
106  static Rotation3D XRotation(double angle);
107 
109  // Construct pure rotation around y-axis.
110  static Rotation3D YRotation(double angle);
111 
113  // Construct pure rotation around z-axis.
114  static Rotation3D ZRotation(double angle);
115 
116 private:
117 
118  // Representation.
120 };
121 
122 
123 // Inline functions.
124 // ------------------------------------------------------------------------
125 
127  R()
128 {}
129 
130 
131 inline bool Rotation3D::operator==(const Rotation3D &rhs) const
132 { return (R == rhs.R); }
133 
134 
135 inline bool Rotation3D::operator!=(const Rotation3D &rhs) const
136 { return (R != rhs.R); }
137 
138 
139 inline double Rotation3D::operator()(int row, int col) const
140 { return R(row, col); }
141 
142 
144  R *= rhs.R;
145  return *this;
146 }
147 
148 
149 inline Rotation3D Rotation3D::operator*(const Rotation3D &rhs) const {
150  Rotation3D result(*this);
151  return result *= rhs;
152 }
153 
154 
155 inline Vector3D Rotation3D::operator*(const Vector3D &rhs) const {
156  return R * rhs;
157 }
158 
159 
160 inline bool Rotation3D::isIdentity() const {
161  return R.isIdentity();
162 }
163 
164 #endif // CLASSIC_Rotation3D_HH
bool isPureYRotation() const
Test for rotation.
Definition: Rotation3D.cpp:116
double operator()(int i, int k) const
Get component.
Definition: Rotation3D.h:139
bool isIdentity() const
Test for identity.
Definition: Rotation3D.h:160
bool operator==(const Rotation3D &) const
Definition: Rotation3D.h:131
Rotation3D inverse() const
Inversion.
Definition: Rotation3D.cpp:98
Rotation3D & operator*=(const Rotation3D &rhs)
Multiply and assign.
Definition: Rotation3D.h:143
bool isPureZRotation() const
Test for rotation.
Definition: Rotation3D.cpp:121
static Rotation3D Identity()
Make identity.
Definition: Rotation3D.cpp:126
Rotation3D()
Default constructor.
Definition: Rotation3D.h:126
bool isIdentity() const
Test for identity.
Definition: Matrix3D.cpp:122
Rotation3D operator*(const Rotation3D &rhs) const
Multiply.
Definition: Rotation3D.h:149
Matrix3D R
Definition: Rotation3D.h:119
bool isPureXRotation() const
Test for rotation.
Definition: Rotation3D.cpp:111
static Rotation3D ZRotation(double angle)
Make rotation.
Definition: Rotation3D.cpp:147
3-dimensional matrix.
Definition: Matrix3D.h:33
bool operator!=(const Rotation3D &) const
Definition: Rotation3D.h:135
A 3-dimension vector.
Definition: Vector3D.h:31
static Rotation3D YRotation(double angle)
Make rotation.
Definition: Rotation3D.cpp:139
static Rotation3D XRotation(double angle)
Make rotation.
Definition: Rotation3D.cpp:131
Rotation in 3-dimensional space.
Definition: Rotation3D.h:46
Vector3D getAxis() const
Get axis vector.
Definition: Rotation3D.cpp:91