OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Rotation3D.h
Go to the documentation of this file.
1#ifndef OPALX_Rotation3D_HH
2#define OPALX_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// Class Rotation3D
27// -----------------------------------------------------------------------
29// There are two possible external representations:
30// [DL]
31// [DT]Matrix3D R[DD]
32// The matrix R is an element of SO(3). Its column vectors define the
33// unit vectors of the rotated coordinate system, expressed in the
34// original system. This representation is used internally and can only
35// be read from a Rotation3D object. To build such an object, use the
36// other representation.
37// [DT]Vector3D V[DD]
38// The direction of V defines the axis of rotation, and its length the
39// sine of half the rotation angle. A zero vector represents the identity.
40// [/DL]
41// The copy constructor, destructor, and assignment operator generated
42// by the compiler perform the correct operation. For speed reasons they
43// are not implemented.
44
46public:
48 // Constructs identity.
49 Rotation3D();
50
52 // Use axis vector (vx,vy,vz).
53 Rotation3D(double vx, double vy, double vz);
54
55 bool operator==(const Rotation3D&) const;
56 bool operator!=(const Rotation3D&) const;
57
59 Rotation3D& operator*=(const Rotation3D& rhs);
60
62 Rotation3D operator*(const Rotation3D& rhs) const;
63
65 // Return vector [b]rhs[/b] rotated by the rotation [b]this[/b].
66 Vector3D operator*(const Vector3D& rhs) const;
67
69 // Return element (i,k) of the orthogonal matrix.
70 double operator()(int i, int k) const;
71
73 // Return the axis vector.
74 Vector3D getAxis() const;
75
77 // Return the axis vector in (vx,vy,vz).
78 void getAxis(double& vx, double& vy, double& vz) const;
79
81 Rotation3D inverse() const;
82
84 bool isIdentity() const;
85
87 // Return true, if [b]this[/b] is a pure x-rotation.
88 bool isPureXRotation() const;
89
91 // Return true, if [b]this[/b] is a pure y-rotation.
92 bool isPureYRotation() const;
93
95 // Return true, if [b]this[/b] is a pure z-rotation.
96 bool isPureZRotation() const;
97
99 static Rotation3D Identity();
100
102 // Construct pure rotation around x-axis.
103 static Rotation3D XRotation(double angle);
104
106 // Construct pure rotation around y-axis.
107 static Rotation3D YRotation(double angle);
108
110 // Construct pure rotation around z-axis.
111 static Rotation3D ZRotation(double angle);
112
113private:
114 // Representation.
116};
117
118// Inline functions.
119// ------------------------------------------------------------------------
120
121inline Rotation3D::Rotation3D() : R() {}
122
123inline bool Rotation3D::operator==(const Rotation3D& rhs) const { return (R == rhs.R); }
124
125inline bool Rotation3D::operator!=(const Rotation3D& rhs) const { return (R != rhs.R); }
126
127inline double Rotation3D::operator()(int row, int col) const { return R(row, col); }
128
130 R *= rhs.R;
131 return *this;
132}
133
135 Rotation3D result(*this);
136 return result *= rhs;
137}
138
139inline Vector3D Rotation3D::operator*(const Vector3D& rhs) const { return R * rhs; }
140
141inline bool Rotation3D::isIdentity() const { return R.isIdentity(); }
142
143#endif // OPALX_Rotation3D_HH
3-dimensional matrix.
Definition Matrix3D.h:32
bool isIdentity() const
Test for identity.
Definition Matrix3D.cpp:108
Rotation in 3-dimensional space.
Definition Rotation3D.h:45
static Rotation3D Identity()
Make identity.
Matrix3D R
Definition Rotation3D.h:115
bool operator!=(const Rotation3D &) const
Definition Rotation3D.h:125
bool isIdentity() const
Test for identity.
Definition Rotation3D.h:141
Rotation3D & operator*=(const Rotation3D &rhs)
Multiply and assign.
Definition Rotation3D.h:129
double operator()(int i, int k) const
Get component.
Definition Rotation3D.h:127
static Rotation3D ZRotation(double angle)
Make rotation.
static Rotation3D YRotation(double angle)
Make rotation.
Rotation3D inverse() const
Inversion.
Rotation3D operator*(const Rotation3D &rhs) const
Multiply.
Definition Rotation3D.h:134
bool isPureXRotation() const
Test for rotation.
Vector3D getAxis() const
Get axis vector.
bool isPureZRotation() const
Test for rotation.
static Rotation3D XRotation(double angle)
Make rotation.
bool isPureYRotation() const
Test for rotation.
Rotation3D()
Default constructor.
Definition Rotation3D.h:121
bool operator==(const Rotation3D &) const
Definition Rotation3D.h:123
A 3-dimension vector.
Definition Vector3D.h:30