septernion.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::septernion
26 
27 Description
28  Septernion class used to perform translations and rotations in 3D space.
29 
30  It is composed of a translation vector and rotation quaternion and as
31  such has seven components hence the name "septernion" from the Latin to
32  be consistent with quaternion rather than "hepternion" derived from the
33  Greek.
34 
35 SourceFiles
36  septernionI.H
37  septernion.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef septernion_H
42 #define septernion_H
43 
44 #include "vector.H"
45 #include "quaternion.H"
46 #include "spatialTransform.H"
47 #include "word.H"
48 #include "contiguous.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of friend functions and operators
56 
57 class septernion;
58 Istream& operator>>(Istream& is, septernion&);
59 Ostream& operator<<(Ostream& os, const septernion& C);
60 
61 
62 /*---------------------------------------------------------------------------*\
63  Class septernion Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class septernion
67 {
68  // private data
69 
70  //- Translation vector
71  vector t_;
72 
73  //- Rotation quaternion
74  quaternion r_;
75 
76 
77 public:
78 
79  // Static Data Members
80 
81  static const char* const typeName;
82 
83  static const septernion zero;
84  static const septernion I;
85 
86 
87  // Constructors
88 
89  //- Construct null
90  inline septernion();
91 
92  //- Construct given a translation vector and rotation quaternion
93  inline septernion(const vector& t, const quaternion& r);
94 
95  //- Construct a pure translation septernion given a translation vector
96  inline explicit septernion(const vector& t);
97 
98  //- Construct a pure rotation septernion given a rotation quaternion
99  inline explicit septernion(const quaternion& r);
100 
101  //- Construct a general septernion from the given spatialTransform
102  inline explicit septernion(const spatialTransform& st);
103 
104  //- Construct from Istream
106 
107 
108  // Member Functions
109 
110  // Access
111 
112  inline const vector& t() const;
113  inline const quaternion& r() const;
114 
115 
116  // Edit
117 
118  inline vector& t();
119  inline quaternion& r();
120 
121 
122  // Transform
123 
124  //- Transform the given coordinate point
125  inline vector transformPoint(const vector& v) const;
126 
127  //- Inverse Transform the given coordinate point
128  inline vector invTransformPoint(const vector& v) const;
129 
130 
131  // Member Operators
132 
133  inline void operator*=(const septernion&);
134 
135  inline void operator=(const vector&);
136  inline void operator+=(const vector&);
137  inline void operator-=(const vector&);
138 
139  inline void operator=(const quaternion&);
140  inline void operator*=(const quaternion&);
141  inline void operator/=(const quaternion&);
142 
143  inline void operator*=(const scalar);
144  inline void operator/=(const scalar);
145 
146 
147  // IOstream Operators
148 
150  friend Ostream& operator<<(Ostream& os, const septernion& C);
151 };
152 
153 
154 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
155 
156 //- Return the inverse of the given septernion
157 inline septernion inv(const septernion& tr);
158 
159 //- Return a string representation of a septernion
160 word name(const septernion&);
161 
162 //- Spherical linear interpolation of septernions. 0 for qa, 1 for qb
164 (
165  const septernion& qa,
166  const septernion& qb,
167  const scalar t
168 );
169 
170 //- Simple weighted average
172 (
173  const UList<septernion>& ss,
174  const UList<scalar> w
175 );
176 
177 //- Data associated with septernion type are contiguous
178 template<>
179 inline bool contiguous<septernion>() {return true;}
180 
181 
182 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
183 
184 inline bool operator==(const septernion& tr1, const septernion& tr2);
185 inline bool operator!=(const septernion& tr1, const septernion& tr2);
186 inline septernion operator+(const septernion& tr, const vector& t);
187 inline septernion operator+(const vector& t, const septernion& tr);
188 inline septernion operator-(const septernion& tr, const vector& t);
189 inline septernion operator*(const quaternion& r, const septernion& tr);
190 inline septernion operator*(const septernion& tr, const quaternion& r);
191 inline septernion operator/(const septernion& tr, const quaternion& r);
192 inline septernion operator*(const septernion& q1, const septernion& q2);
193 inline septernion operator/(const septernion& q1, const septernion& q2);
194 inline septernion operator*(const scalar s, const septernion& tr);
195 inline septernion operator*(const septernion& tr, const scalar s);
196 inline septernion operator/(const septernion& tr, const scalar s);
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #include "septernionI.H"
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************************************************************* //
static const Foam::dimensionedScalar C("C", Foam::dimTemperature, 234.5)
Graphite solid properties.
Definition: C.H:51
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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:74
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:61
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:66
vector invTransformPoint(const vector &v) const
Inverse Transform the given coordinate point.
Definition: septernionI.H:88
friend Istream & operator>>(Istream &is, septernion &)
void operator*=(const septernion &)
Definition: septernionI.H:96
void operator=(const vector &)
Definition: septernionI.H:103
void operator+=(const vector &)
Definition: septernionI.H:109
const quaternion & r() const
Definition: septernionI.H:64
vector transformPoint(const vector &v) const
Transform the given coordinate point.
Definition: septernionI.H:82
void operator-=(const vector &)
Definition: septernionI.H:114
static const septernion zero
Definition: septernion.H:82
static const septernion I
Definition: septernion.H:83
septernion()
Construct null.
Definition: septernionI.H:28
const vector & t() const
Definition: septernionI.H:58
friend Ostream & operator<<(Ostream &os, const septernion &C)
static const char *const typeName
Definition: septernion.H:80
void operator/=(const quaternion &)
Definition: septernionI.H:132
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
A class for handling words, derived from string.
Definition: word.H:62
Template function to specify if the data of a type are contiguous.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
bool operator!=(const particle &, const particle &)
Definition: particle.C:1210
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Istream & operator>>(Istream &, pistonPointEdgeData &)
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
Definition: quaternion.C:55
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator/(const fvMatrix< Type > &, const volScalarField::Internal &)
bool contiguous< septernion >()
Data associated with septernion type are contiguous.
Definition: septernion.H:178