axisAngleRotation.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) 2018-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::coordinateRotations::axisAngle
28 
29 Description
30  A coordinateRotation specified by a rotation axis and a rotation angle
31  about that axis.
32 
33  \verbatim
34  rotation
35  {
36  type axisAngle;
37  axis (1 0 0);
38  angle 90;
39  }
40  \endverbatim
41 
42  \heading Dictionary entries
43  \table
44  Property | Description | Required | Default
45  type | Type name: axisAngle | yes |
46  axis | Axis of rotation (vector) | yes |
47  angle | Rotation angle | yes |
48  degrees | The angle is in degrees | no | true
49  \endtable
50 
51 Note
52  The rotation axis will be normalized internally.
53 
54 SourceFiles
55  axisAngleRotation.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef coordinateRotations_axisAngle_H
60 #define coordinateRotations_axisAngle_H
61 
62 #include "coordinateRotation.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 namespace coordinateRotations
69 {
70 
71 /*---------------------------------------------------------------------------*\
72  Class coordinateRotations::axisAngle Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class axisAngle
76 :
77  public coordinateRotation
78 {
79  // Private Data
80 
81  //- The rotation axis
82  vector axis_;
83 
84  //- The rotation angle
85  scalar angle_;
86 
87  //- Angle measured in degrees
88  bool degrees_;
89 
90 
91  // Private Member Functions
92 
93  //- Check specification for an identity rotation
94  void checkSpec();
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeNameNoDebug("axisAngle");
101 
102 
103  // Constructors
104 
105  //- Default construct. Axis = Z, angle = 0.
106  axisAngle();
107 
108  //- Copy construct
109  axisAngle(const axisAngle& crot);
110 
111  //- Construct from axis and angle
112  axisAngle(const vector& axis, scalar angle, bool degrees);
113 
114  //- Construct from x/y/z axis enumeration and angle
115  axisAngle(const vector::components axis, scalar angle, bool degrees);
116 
117  //- Construct from dictionary
118  explicit axisAngle(const dictionary& dict);
119 
120  //- Return clone
122  {
123  return
126  }
127 
128 
129  //- Destructor
130  virtual ~axisAngle() = default;
131 
132 
133  // Static Member Functions
134 
135  //- The rotation tensor for given axis/angle
136  static tensor rotation
137  (
138  const vector& axis,
139  const scalar angle,
140  bool degrees=false
141  );
142 
143 
144  // Member Functions
145 
146  //- Reset specification
147  virtual void clear();
148 
149  //- Calculate and return the rotation tensor
150  //- calculated from axis and angle
151  virtual tensor R() const;
152 
153  //- Write information
154  virtual void write(Ostream& os) const;
155 
156  //- Write dictionary entry
157  virtual void writeEntry(const word& keyword, Ostream& os) const;
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace coordinateRotations
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::coordinateRotations::axisAngle::writeEntry
virtual void writeEntry(const word &keyword, Ostream &os) const
Write dictionary entry.
Definition: axisAngleRotation.C:168
Foam::coordinateRotations::axisAngle::clone
autoPtr< coordinateRotation > clone() const
Return clone.
Definition: axisAngleRotation.H:145
Foam::coordinateRotations::axisAngle
A coordinateRotation specified by a rotation axis and a rotation angle about that axis.
Definition: axisAngleRotation.H:99
Foam::coordinateRotations::axisAngle::TypeNameNoDebug
TypeNameNoDebug("axisAngle")
Runtime type information.
Foam::Vector< scalar >::components
components
Component labeling enumeration.
Definition: Vector.H:81
Foam::coordinateRotations::axisAngle::rotation
static tensor rotation(const vector &axis, const scalar angle, bool degrees=false)
The rotation tensor for given axis/angle.
Definition: axisAngleRotation.C:65
Foam::coordinateRotations::axisAngle::axisAngle
axisAngle()
Default construct. Axis = Z, angle = 0.
Definition: axisAngleRotation.C:82
Foam::coordinateRotation
User specification of a coordinate rotation.
Definition: coordinateRotation.H:78
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::coordinateRotations::axisAngle::write
virtual void write(Ostream &os) const
Write information.
Definition: axisAngleRotation.C:160
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Vector< scalar >
Foam::coordinateRotations::axisAngle::R
virtual tensor R() const
Definition: axisAngleRotation.C:154
coordinateRotation.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::coordinateRotations::axisAngle::~axisAngle
virtual ~axisAngle()=default
Destructor.
Foam::coordinateRotations::axisAngle::clear
virtual void clear()
Reset specification.
Definition: axisAngleRotation.C:147