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
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 );
198 
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 // ************************************************************************* //
Foam::septernion::operator/=
void operator/=(const quaternion &)
Definition: septernionI.H:146
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::septernion
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:66
s
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))
Definition: gmvOutputSpray.H:25
Foam::spatialTransform
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
Definition: spatialTransform.H:70
Foam::slerp
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
Definition: quaternion.C:78
quaternion.H
Foam::operator-
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Foam::septernion::zero
static const septernion zero
Definition: septernion.H:83
Foam::septernion::operator<<
friend Ostream & operator<<(Ostream &os, const septernion &C)
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
C
volScalarField & C
Definition: readThermalProperties.H:102
Foam::quaternion
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:56
Foam::septernion::operator*=
void operator*=(const septernion &)
Definition: septernionI.H:106
Foam::operator!=
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:239
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::septernion::operator>>
friend Istream & operator>>(Istream &is, septernion &)
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:73
Foam::septernion::t
const vector & t() const
Definition: septernionI.H:68
Foam::septernion::operator-=
void operator-=(const vector &)
Definition: septernionI.H:126
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::is_contiguous_scalar
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:91
Foam::operator/
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
Definition: dimensionedScalar.C:68
Foam::septernion::operator=
septernion & operator=(const septernion &)=default
Copy assignment.
Foam::septernion::operator+=
void operator+=(const vector &)
Definition: septernionI.H:120
Foam::Vector< scalar >
Foam::operator+
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::operator*
tmp< faMatrix< Type > > operator*(const areaScalarField &, const faMatrix< Type > &)
Foam::UList
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:103
spatialTransform.H
Foam::septernion::I
static const septernion I
Definition: septernion.H:84
vector.H
Foam::septernion::r
const quaternion & r() const
Definition: septernionI.H:74
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:51
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
word.H
Foam::septernion::invTransformPoint
vector invTransformPoint(const vector &v) const
Inverse Transform the given coordinate point.
Definition: septernionI.H:98
Foam::septernion::typeName
static const char *const typeName
Definition: septernion.H:81
Foam::C
Graphite solid properties.
Definition: C.H:50
Foam::septernion::transformPoint
vector transformPoint(const vector &v) const
Transform the given coordinate point.
Definition: septernionI.H:92
Foam::septernion::septernion
septernion()=default
Default construct.
septernionI.H
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
Foam::is_contiguous
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:75
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62