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-2019 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  coordinateRotation
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  // Constructors
103 
104  //- Construct null
105  axisAngle();
106 
107  //- Copy construct
108  axisAngle(const axisAngle& crot);
109 
110  //- Move construct
111  axisAngle(axisAngle&& crot);
112 
113  //- Construct from axis and angle
114  axisAngle(const vector& axis, scalar angle, bool degrees);
115 
116  //- Construct from x/y/z axis enumeration and angle
117  axisAngle(const vector::components axis, scalar angle, bool degrees);
118 
119  //- Construct from dictionary
120  explicit axisAngle(const dictionary& dict);
121 
122  //- Return clone
124  {
125  return
128  }
129 
130 
131  //- Destructor
132  virtual ~axisAngle() = default;
133 
134 
135  // Static Member Functions
136 
137  //- The rotation tensor for given axis/angle
138  static tensor rotation
139  (
140  const vector& axis,
141  const scalar angle,
142  bool degrees=false
143  );
144 
145 
146  // Member Functions
147 
148  //- Reset specification
149  virtual void clear();
150 
151  //- Calculate and return the rotation tensor
152  //- calculated from axis and angle
153  virtual tensor R() const;
154 
155  //- Write information
156  virtual void write(Ostream& os) const;
157 
158  //- Write dictionary entry
159  virtual void writeEntry(const word& keyword, Ostream& os) const;
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace coordinateRotations
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::coordinateRotations::axisAngle::writeEntry
virtual void writeEntry(const word &keyword, Ostream &os) const
Write dictionary entry.
Definition: axisAngleRotation.C:179
Foam::coordinateRotations::axisAngle::clone
autoPtr< coordinateRotation > clone() const
Return clone.
Definition: axisAngleRotation.H:147
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::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()
Construct null.
Definition: axisAngleRotation.C:82
Foam::coordinateRotation
User specification of a coordinate rotation.
Definition: coordinateRotation.H:77
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:121
Foam::coordinateRotations::axisAngle::write
virtual void write(Ostream &os) const
Write information.
Definition: axisAngleRotation.C:171
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:165
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:158