OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Euclid3D.h
Go to the documentation of this file.
1#ifndef OPALX_Euclid3D_HH
2#define OPALX_Euclid3D_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: Euclid3D.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: Euclid3D
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 Euclid3D
27// ------------------------------------------------------------------------
29// An arbitrary 3-dimension translation and rotation.
30// The translation is a 3-dimensional vector, the rotation is represented
31// as a 3-dimensional orthonormal matrix.
32// {P}
33// If we think of an Euler3D object as an operator E which transforms a
34// point in the super-frame X to the local frame X':
35// {P}
36// X' = E(X),
37// {P}
38// then we can define a dot product of two successive operations in the
39// following way: Given two Euclid3D objects (operators) E1 and E2,
40// we can define
41// {P}
42// E3 = E2 . E1
43// {P}
44// using
45// {P}
46// X''= E3(X) = E2(E1(X)).
47// {P}
48// The definition of a multiplicative inverse naturally follows as
49// {P}
50// E . inv(E) = I.
51// {P}
52// If R represents the 3-d rotation and X the vector specified by
53// (x,y,z), then a transformation of a point P in the super-frame by
54// the Euclid3D is given by
55// {P}
56// P -> R . P + X.
57// {P}
58// For the representation of rotations, see Rotation3D.
59// The copy constructor, destructor, and assignment operator generated
60// by the compiler perform the correct operation. For speed reasons they
61// are not implemented.
62// An alternate representation for the rotation is given by a vector
63// pointing in the direction of the axis of rotation, whose sense is
64// given by the right-hand rule, and whose length is equal to the angle
65// of rotation.
66
67class Euclid3D {
68public:
70 // Construct identity.
71 Euclid3D();
72
74 // Use displacement [b]V[/b] and rotation [b]R[/b].
75 Euclid3D(const Vector3D& V, const Rotation3D& R);
76
78 // Use displacement (x,y,z) and rotation (vx,vy,vz).
79 Euclid3D(double x, double y, double z, double vx, double vy, double vz);
80
81 bool operator==(const Euclid3D&) const;
82 bool operator!=(const Euclid3D&) const;
83
85 // Return the displacement in (x,y,z) and the rotation axis in (vx,vy,vz).
86 void getAll(double& x, double& y, double& z, double& vx, double& vy, double& vz) const;
87
89 // Return x-component of displacement.
90 double getX() const;
91
93 // Return x-component of displacement.
94 double getY() const;
95
97 // Return x-component of displacement.
98 double getZ() const;
99
101 // Return displacement as a vector.
102 const Vector3D& getVector() const;
103
105 // Return rotation as an orthogonal matrix.
106 const Rotation3D& getRotation() const;
107
109 // Return the component (row,col) of the rotation matrix.
110 double M(int row, int col) const;
111
113 // Assign x-component of displacement.
114 void setX(double x);
115
117 // Assign y-component of displacement.
118 void setY(double y);
119
121 // Assign z-component of displacement.
122 void setZ(double z);
123
125 // Assign displacement as a vector.
126 void setDisplacement(const Vector3D& V);
127
129 // Assign rotation as an orthogonal matrix.
130 void setRotation(const Rotation3D& R);
131
133 // Return composition of [b]this[/b] with [b]rhs[/b].
134 Euclid3D dot(const Euclid3D& rhs) const;
135
137 // Return composition of [b]this[/b] with [b]rhs[/b].
138 const Euclid3D& dotBy(const Euclid3D& rhs);
139
141 // Return composition of [b]this[/b] with [b]rhs[/b].
142 Euclid3D operator*(const Euclid3D& rhs) const;
143
145 const Euclid3D& operator*=(const Euclid3D& rhs);
146
148 Euclid3D inverse() const;
149
151 bool isIdentity() const;
152
154 // Return true, if [b]this[/b] is a pure translation.
155 bool isPureTranslation() const;
156
158 // Return true, if [b]this[/b] is a pure x-rotation.
159 bool isPureXRotation() const;
160
162 // Return true, if [b]this[/b] is a pure y-rotation.
163 bool isPureYRotation() const;
164
166 // Return true, if [b]this[/b] is a pure z-rotation.
167 bool isPureZRotation() const;
168
170 static Euclid3D identity();
171
173 // Use displacement (x,y,z).
174 static Euclid3D translation(double x, double y, double z);
175
177 // Construct pure rotation by [b]angle[/b] around the x-axis;
178 static Euclid3D XRotation(double angle);
179
181 // Construct pure rotation by [b]angle[/b] around the y-axis;
182 static Euclid3D YRotation(double angle);
183
185 // Construct pure rotation by [b]angle[/b] around the z-axis;
186 static Euclid3D ZRotation(double angle);
187
188private:
189 // Implementation.
190 Vector3D V; // The displacement.
191 Rotation3D R; // The rotation.
192 mutable bool is_identity; // True, when [b]this[/b] is identity.
193};
194
195// Global Function.
196// ------------------------------------------------------------------------
197
199inline Euclid3D Inverse(const Euclid3D& t) { return t.inverse(); }
200
201// Trivial functions are inlined.
202// ------------------------------------------------------------------------
203
204inline Euclid3D::Euclid3D() : V(), R(), is_identity(true) {}
205
206inline double Euclid3D::getX() const { return V.getX(); }
207
208inline double Euclid3D::getY() const { return V.getY(); }
209
210inline double Euclid3D::getZ() const { return V.getZ(); }
211
212inline double Euclid3D::M(int row, int col) const { return R(row, col); }
213
214inline bool Euclid3D::isIdentity() const { return is_identity; }
215
216#endif // OPALX_Euclid3D_HH
Euclid3D Inverse(const Euclid3D &t)
Euclidean inverse.
Definition Euclid3D.h:199
Displacement and rotation in space.
Definition Euclid3D.h:67
bool is_identity
Definition Euclid3D.h:192
static Euclid3D ZRotation(double angle)
Make rotation.
Definition Euclid3D.cpp:115
void setZ(double z)
Set displacement.
Definition Euclid3D.cpp:53
void setX(double x)
Set displacement.
Definition Euclid3D.cpp:49
double getX() const
Get displacement.
Definition Euclid3D.h:206
double getY() const
Get displacement.
Definition Euclid3D.h:208
Vector3D V
Definition Euclid3D.h:190
bool isPureXRotation() const
Test for rotation.
Definition Euclid3D.cpp:91
void setY(double y)
Set displacement.
Definition Euclid3D.cpp:51
void getAll(double &x, double &y, double &z, double &vx, double &vy, double &vz) const
Unpack.
Definition Euclid3D.cpp:40
double M(int row, int col) const
Get component.
Definition Euclid3D.h:212
static Euclid3D YRotation(double angle)
Make rotation.
Definition Euclid3D.cpp:109
bool operator==(const Euclid3D &) const
Definition Euclid3D.cpp:36
Euclid3D()
Default constructor.
Definition Euclid3D.h:204
void setDisplacement(const Vector3D &V)
Set displacement.
Definition Euclid3D.cpp:55
bool operator!=(const Euclid3D &) const
Definition Euclid3D.cpp:38
const Euclid3D & operator*=(const Euclid3D &rhs)
Dot product with assign.
Definition Euclid3D.cpp:82
static Euclid3D XRotation(double angle)
Make rotation.
Definition Euclid3D.cpp:103
const Euclid3D & dotBy(const Euclid3D &rhs)
Dot product with assign.
Definition Euclid3D.cpp:70
const Vector3D & getVector() const
Get displacement.
Definition Euclid3D.cpp:45
bool isPureYRotation() const
Test for rotation.
Definition Euclid3D.cpp:93
Euclid3D inverse() const
Inverse.
Definition Euclid3D.cpp:84
bool isIdentity() const
Test for identity.
Definition Euclid3D.h:214
void setRotation(const Rotation3D &R)
Set rotation.
Definition Euclid3D.cpp:60
static Euclid3D identity()
Make identity.
Definition Euclid3D.cpp:97
Euclid3D operator*(const Euclid3D &rhs) const
Dot product.
Definition Euclid3D.cpp:77
static Euclid3D translation(double x, double y, double z)
Make translation.
Definition Euclid3D.cpp:99
Rotation3D R
Definition Euclid3D.h:191
bool isPureZRotation() const
Test for rotation.
Definition Euclid3D.cpp:95
Euclid3D dot(const Euclid3D &rhs) const
Dot product.
Definition Euclid3D.cpp:65
double getZ() const
Get displacement.
Definition Euclid3D.h:210
bool isPureTranslation() const
Test for translation.
Definition Euclid3D.cpp:89
const Rotation3D & getRotation() const
Get rotation.
Definition Euclid3D.cpp:47
Rotation in 3-dimensional space.
Definition Rotation3D.h:45
A 3-dimension vector.
Definition Vector3D.h:30
double getY() const
Get component.
Definition Vector3D.h:134
double getX() const
Get component.
Definition Vector3D.h:132
double getZ() const
Get component.
Definition Vector3D.h:136