septernion.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-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2020 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::septernion
29 
30 Description
31  Septernion class used to perform translations and rotations in 3D space.
32 
33  It is composed of a translation vector and rotation quaternion and as
34  such has seven components hence the name "septernion" from the Latin to
35  be consistent with quaternion rather than "hepternion" derived from the
36  Greek.
37 
38 SourceFiles
39  septernionI.H
40  septernion.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef septernion_H
45 #define septernion_H
46 
47 #include "vector.H"
48 #include "quaternion.H"
49 #include "spatialTransform.H"
50 #include "word.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward Declarations
58 class septernion;
59 Istream& operator>>(Istream& is, septernion&);
60 Ostream& operator<<(Ostream& os, const septernion& C);
61 
62 
63 /*---------------------------------------------------------------------------*\
64  Class septernion Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class septernion
68 {
69  // Private Data
70 
71  //- Translation vector
72  vector t_;
73 
74  //- Rotation quaternion
75  quaternion r_;
76 
77 
78 public:
79 
80  // Static Data
81 
82  static const char* const typeName;
83 
84  static const septernion zero;
85  static const septernion I;
86 
87 
88  // Generated Methods
89 
90  //- Default construct
91  septernion() = default;
92 
93  //- Copy construct
94  septernion(const septernion&) = default;
95 
96  //- Copy assignment
97  septernion& operator=(const septernion&) = default;
98 
99 
100  // Constructors
101 
102  //- Construct zero initialized
103  inline septernion(const Foam::zero);
104 
105  //- Construct given a translation vector and rotation quaternion
106  inline septernion(const vector& t, const quaternion& r);
107 
108  //- Construct a pure translation septernion given a translation vector
109  inline explicit septernion(const vector& t);
110 
111  //- Construct a pure rotation septernion given a rotation quaternion
112  inline explicit septernion(const quaternion& r);
113 
114  //- Construct a general septernion from the given spatialTransform
115  inline explicit septernion(const spatialTransform& st);
116 
117  //- Construct from Istream
118  explicit septernion(Istream& is);
119 
120 
121  // Member Functions
122 
123  // Access
124 
125  inline const vector& t() const;
126  inline const quaternion& r() const;
127 
128 
129  // Edit
130 
131  inline vector& t();
132  inline quaternion& r();
133 
134 
135  // Transform
136 
137  //- Transform the given coordinate point
138  inline vector transformPoint(const vector& v) const;
139 
140  //- Inverse Transform the given coordinate point
141  inline vector invTransformPoint(const vector& v) const;
142 
143 
144  // Member Operators
145 
146  inline void operator*=(const septernion&);
147 
148  inline void operator=(const vector&);
149  inline void operator+=(const vector&);
150  inline void operator-=(const vector&);
151 
152  inline void operator=(const quaternion&);
153  inline void operator*=(const quaternion&);
154  inline void operator/=(const quaternion&);
155 
156  inline void operator*=(const scalar);
157  inline void operator/=(const scalar);
158 
159 
160  // IOstream Operators
161 
162  friend Istream& operator>>(Istream& is, septernion&);
163  friend Ostream& operator<<(Ostream& os, const septernion& C);
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
168 
169 //- Contiguous data for septernion
170 template<> struct is_contiguous<septernion> : std::true_type {};
171 
172 //- Contiguous scalar data for septernion
173 template<> struct is_contiguous_scalar<septernion> : std::true_type {};
174 
175 
176 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
177 
178 //- Return the inverse of the given septernion
179 inline septernion inv(const septernion& tr);
180 
181 //- Return a string representation of a septernion
182 word name(const septernion&);
183 
184 //- Spherical linear interpolation of septernions. 0 for qa, 1 for qb
185 septernion slerp
186 (
187  const septernion& qa,
188  const septernion& qb,
189  const scalar t
190 );
191 
192 //- Simple weighted average
194 (
195  const UList<septernion>& ss,
196  const UList<scalar> w
197 );
199 
200 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
201 
202 inline bool operator==(const septernion& tr1, const septernion& tr2);
203 inline bool operator!=(const septernion& tr1, const septernion& tr2);
204 inline septernion operator+(const septernion& tr, const vector& t);
205 inline septernion operator+(const vector& t, const septernion& tr);
206 inline septernion operator-(const septernion& tr, const vector& t);
207 inline septernion operator*(const quaternion& r, const septernion& tr);
208 inline septernion operator*(const septernion& tr, const quaternion& r);
209 inline septernion operator/(const septernion& tr, const quaternion& r);
210 inline septernion operator*(const septernion& q1, const septernion& q2);
211 inline septernion operator/(const septernion& q1, const septernion& q2);
212 inline septernion operator*(const scalar s, const septernion& tr);
213 inline septernion operator*(const septernion& tr, const scalar s);
214 inline septernion operator/(const septernion& tr, const scalar s);
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #include "septernionI.H"
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #endif
228 
229 // ************************************************************************* //
Graphite solid properties.
Definition: C.H:46
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:62
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
void operator*=(const septernion &)
Definition: septernionI.H:99
void operator-=(const vector &)
Definition: septernionI.H:119
friend Istream & operator>>(Istream &is, septernion &)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
Istream & operator>>(Istream &, directionInfo &)
septernion & operator=(const septernion &)=default
Copy assignment.
friend Ostream & operator<<(Ostream &os, const septernion &C)
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:53
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
static const septernion I
Definition: septernion.H:84
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
septernion()=default
Default construct.
void operator/=(const quaternion &)
Definition: septernionI.H:139
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
volScalarField & C
void operator+=(const vector &)
Definition: septernionI.H:113
vector invTransformPoint(const vector &v) const
Inverse Transform the given coordinate point.
Definition: septernionI.H:91
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
A template class to specify that a data type can be considered as being contiguous in memory...
Definition: contiguous.H:70
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
Definition: quaternion.C:75
const vector & t() const
Definition: septernionI.H:61
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:297
const quaternion & r() const
Definition: septernionI.H:67
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
vector transformPoint(const vector &v) const
Transform the given coordinate point.
Definition: septernionI.H:85
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static const char *const typeName
Definition: septernion.H:81
Namespace for OpenFOAM.
static const septernion zero
Definition: septernion.H:83