EulerCoordinateRotation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2017-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::coordinateRotations::euler
29 
30 Description
31  A coordinateRotation defined in the z-x-z (intrinsic) Euler convention.
32 
33  The 3 rotations are defined in the Euler intrinsic convention
34  (around Z, around X' and around Z'').
35  The order of the parameter arguments matches this rotation order.
36 
37  For reference and illustration, see
38  https://en.wikipedia.org/wiki/Euler_angles
39 
40  \verbatim
41  rotation
42  {
43  type euler;
44  angles (0 0 180);
45  }
46  \endverbatim
47 
48  \heading Dictionary entries
49  \table
50  Property | Description | Reqd | Default
51  type | Type name: euler | yes |
52  angles | Rotation angles (usually z-x-z order) | yes |
53  degrees | Angles are in degrees | no | true
54  order | Rotation order | no | zxz
55  \endtable
56 
57 Note
58  The rotation order is usually z-x-z, but can also be something like
59  "rollPitchYaw" etc.
60  Also accepts "EulerRotation" (OpenFOAM-v1806) for the type.
61 
62 SourceFiles
63  EulerCoordinateRotation.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef Foam_coordinateRotations_euler_H
68 #define Foam_coordinateRotations_euler_H
69 
70 #include "coordinateRotation.H"
71 #include "quaternion.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace coordinateRotations
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class coordinateRotations::euler Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class euler
85 :
86  public coordinateRotation
87 {
88 public:
89 
90  // Public Types
91 
92  //- Euler-angle rotation order
94 
95 
96 private:
97 
98  // Private Data
99 
100  //- The rotation angles
101  vector angles_;
102 
103  //- Angles measured in degrees
104  bool degrees_;
105 
106  //- The Euler-angle rotation order (default: zxz)
107  eulerOrder order_;
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeNameNoDebug("euler");
114 
116  // Constructors
117 
118  //- Default construct - an identity transform
119  euler();
120 
121  //- Copy construct
122  euler(const euler& crot);
123 
124  //- Construct from Euler intrinsic rotation angles (z-x-z)
125  euler(const vector& angles, bool degrees);
126 
127  //- Construct from Euler intrinsic rotation angles (z-x-z)
128  euler(scalar angle1, scalar angle2, scalar angle3, bool degrees);
129 
130  //- Construct from dictionary
131  explicit euler(const dictionary& dict);
132 
133  //- Return clone
135  {
136  return coordinateRotation::Clone(*this);
137  }
138 
139 
140  //- Destructor
141  virtual ~euler() = default;
142 
143 
144  // Static Member Functions
145 
146  //- Rotation tensor calculated for the intrinsic Euler
147  //- angles in z-x-z order
148  static tensor rotation(const vector& angles, bool degrees=false);
149 
150  //- Rotation tensor calculated for given order and angles
151  static tensor rotation
152  (
153  const eulerOrder order,
154  const vector& angles,
155  bool degrees=false
156  );
157 
158 
159  // Member Functions
160 
161  //- Reset specification
162  virtual void clear();
163 
164  //- The rotation tensor calculated for the specified Euler angles.
165  virtual tensor R() const;
166 
167  //- Write information
168  virtual void write(Ostream& os) const;
169 
170  //- Write dictionary entry
171  virtual void writeEntry(const word& keyword, Ostream& os) const;
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 } // End namespace coordinateRotations
178 
179 //- Compatibility typedef 1806
181 
182 } // End namespace Foam
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
dictionary dict
coordinateRotations::euler EulerCoordinateRotation
Compatibility typedef 1806.
TypeNameNoDebug("euler")
Runtime type information.
virtual tensor R() const
The rotation tensor calculated for the specified Euler angles.
static autoPtr< coordinateRotation > Clone(const Derived &crot)
Clone a coordinate rotation.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
quaternion::eulerOrder eulerOrder
Euler-angle rotation order.
virtual ~euler()=default
Destructor.
virtual void clear()
Reset specification.
A coordinateRotation defined in the z-x-z (intrinsic) Euler convention.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void writeEntry(const word &keyword, Ostream &os) const
Write dictionary entry.
Vector< scalar > vector
Definition: vector.H:57
eulerOrder
Euler-angle rotation order.
Definition: quaternion.H:115
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
static tensor rotation(const vector &angles, bool degrees=false)
Rotation tensor calculated for the intrinsic Euler angles in z-x-z order.
euler()
Default construct - an identity transform.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Tensor of scalars, i.e. Tensor<scalar>.
virtual void write(Ostream &os) const
Write information.
autoPtr< coordinateRotation > clone() const
Return clone.
Namespace for OpenFOAM.