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-2024 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 | Reqd | 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 is normalized internally.
53 
54 SourceFiles
55  axisAngleRotation.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef Foam_coordinateRotations_axisAngle_H
60 #define Foam_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 coordinateRotation::Clone(*this);
124  }
125 
126 
127  //- Destructor
128  virtual ~axisAngle() = default;
129 
130 
131  // Static Member Functions
132 
133  //- The rotation tensor for given axis/angle
134  static tensor rotation
135  (
136  const vector& axis,
137  const scalar angle,
138  bool degrees=false
139  );
140 
141  //- Rotation tensor calculated for given axis and angle
142  static tensor rotation
143  (
144  const vector::components axis,
145  const scalar angle,
146  bool degrees=false
147  );
148 
149 
150  // Member Functions
151 
152  //- Reset specification
153  virtual void clear();
154 
155  //- Calculate and return the rotation tensor
156  //- calculated from axis and angle
157  virtual tensor R() const;
158 
159  //- Write information
160  virtual void write(Ostream& os) const;
161 
162  //- Write dictionary entry
163  virtual void writeEntry(const word& keyword, Ostream& os) const;
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace coordinateRotations
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
TypeNameNoDebug("axisAngle")
Runtime type information.
virtual void write(Ostream &os) const
Write information.
dictionary dict
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:130
virtual void clear()
Reset specification.
autoPtr< coordinateRotation > clone() const
Return clone.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Vector< scalar > vector
Definition: vector.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual ~axisAngle()=default
Destructor.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
axisAngle()
Default construct. Axis = Z, angle = 0.
static tensor rotation(const vector &axis, const scalar angle, bool degrees=false)
The rotation tensor for given axis/angle.
components
Component labeling enumeration.
Definition: Vector.H:83
A coordinateRotation specified by a rotation axis and a rotation angle about that axis...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual void writeEntry(const word &keyword, Ostream &os) const
Write dictionary entry.
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.
virtual tensor R() const
Calculate and return the rotation tensor calculated from axis and angle.