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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::septernion
29
30Description
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
38SourceFiles
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
54namespace Foam
55{
56
57// Forward Declarations
58class septernion;
59Istream& operator>>(Istream& is, septernion&);
60Ostream& operator<<(Ostream& os, const septernion& C);
61
62
63/*---------------------------------------------------------------------------*\
64 Class septernion Declaration
65\*---------------------------------------------------------------------------*/
67class septernion
68{
69 // Private Data
70
71 //- Translation vector
72 vector t_;
73
74 //- Rotation quaternion
75 quaternion r_;
76
77
78public:
79
80 // Static Data
82 static const char* const typeName;
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
163 friend Ostream& operator<<(Ostream& os, const septernion& C);
164};
165
166
167// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
168
169//- Contiguous data for septernion
170template<> struct is_contiguous<septernion> : std::true_type {};
171
172//- Contiguous scalar data for septernion
173template<> struct is_contiguous_scalar<septernion> : std::true_type {};
174
175
176// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
177
178//- Return the inverse of the given septernion
179inline septernion inv(const septernion& tr);
180
181//- Return a string representation of a septernion
182word 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
202inline bool operator==(const septernion& tr1, const septernion& tr2);
203inline bool operator!=(const septernion& tr1, const septernion& tr2);
204inline septernion operator+(const septernion& tr, const vector& t);
205inline septernion operator+(const vector& t, const septernion& tr);
206inline septernion operator-(const septernion& tr, const vector& t);
207inline septernion operator*(const quaternion& r, const septernion& tr);
208inline septernion operator*(const septernion& tr, const quaternion& r);
209inline septernion operator/(const septernion& tr, const quaternion& r);
210inline septernion operator*(const septernion& q1, const septernion& q2);
211inline septernion operator/(const septernion& q1, const septernion& q2);
212inline septernion operator*(const scalar s, const septernion& tr);
213inline septernion operator*(const septernion& tr, const scalar s);
214inline 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// ************************************************************************* //
static const Foam::dimensionedScalar C("", Foam::dimTemperature, 234.5)
Graphite solid properties.
Definition: C.H:53
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:58
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:67
vector invTransformPoint(const vector &v) const
Inverse Transform the given coordinate point.
Definition: septernionI.H:98
void operator*=(const septernion &)
Definition: septernionI.H:106
void operator+=(const vector &)
Definition: septernionI.H:120
septernion()=default
Default construct.
const quaternion & r() const
Definition: septernionI.H:74
vector transformPoint(const vector &v) const
Transform the given coordinate point.
Definition: septernionI.H:92
septernion(const septernion &)=default
Copy construct.
septernion & operator=(const septernion &)=default
Copy assignment.
void operator-=(const vector &)
Definition: septernionI.H:126
friend Ostream & operator<<(Ostream &os, const septernion &C)
static const septernion zero
Definition: septernion.H:83
static const septernion I
Definition: septernion.H:84
const vector & t() const
Definition: septernionI.H:68
static const char *const typeName
Definition: septernion.H:81
void operator/=(const quaternion &)
Definition: septernionI.H:146
friend Istream & operator>>(Istream &is, septernion &)
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
A class for handling words, derived from Foam::string.
Definition: word.H:68
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
OBJstream os(runTime.globalPath()/outputName)
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))
Namespace for OpenFOAM.
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:239
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Istream & operator>>(Istream &, directionInfo &)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
Definition: quaternion.C:82
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:94
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:78