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 | Copyright (C) 2011-2016 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  inline void operator*=(const septernion&);
135 
136  inline void operator=(const vector&);
137  inline void operator+=(const vector&);
138  inline void operator-=(const vector&);
139 
140  inline void operator=(const quaternion&);
141  inline void operator*=(const quaternion&);
142  inline void operator/=(const quaternion&);
143 
144  inline void operator*=(const scalar);
145  inline void operator/=(const scalar);
146 
147 
148  // IOstream operators
149 
150  friend Istream& operator>>(Istream& is, septernion&);
151  friend Ostream& operator<<(Ostream& os, const septernion& C);
152 };
153 
154 
155 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
156 
157 //- Return the inverse of the given septernion
158 inline septernion inv(const septernion& tr);
159 
160 //- Return a string representation of a septernion
161 word name(const septernion&);
162 
163 //- Spherical linear interpolation of septernions. 0 for qa, 1 for qb
165 (
166  const septernion& qa,
167  const septernion& qb,
168  const scalar t
169 );
170 
171 //- Simple weighted average
173 (
174  const UList<septernion>& ss,
175  const UList<scalar> w
176 );
177 
178 //- Data associated with septernion type are contiguous
179 template<>
180 inline bool contiguous<septernion>() {return true;}
181 
182 
183 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
184 
185 inline bool operator==(const septernion& tr1, const septernion& tr2);
186 inline bool operator!=(const septernion& tr1, const septernion& tr2);
187 inline septernion operator+(const septernion& tr, const vector& t);
188 inline septernion operator+(const vector& t, const septernion& tr);
189 inline septernion operator-(const septernion& tr, const vector& t);
190 inline septernion operator*(const quaternion& r, const septernion& tr);
191 inline septernion operator*(const septernion& tr, const quaternion& r);
192 inline septernion operator/(const septernion& tr, const quaternion& r);
193 inline septernion operator*(const septernion& q1, const septernion& q2);
194 inline septernion operator/(const septernion& q1, const septernion& q2);
195 inline septernion operator*(const scalar s, const septernion& tr);
196 inline septernion operator*(const septernion& tr, const scalar s);
197 inline septernion operator/(const septernion& tr, const scalar s);
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 #include "septernionI.H"
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
Graphite solid properties.
Definition: C.H:48
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
Template function to specify if the data of a type are contiguous.
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:65
septernion()
Construct null.
Definition: septernionI.H:28
void operator*=(const septernion &)
Definition: septernionI.H:102
void operator-=(const vector &)
Definition: septernionI.H:120
friend Istream & operator>>(Istream &is, septernion &)
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
Istream & operator>>(Istream &, directionInfo &)
friend Ostream & operator<<(Ostream &os, const septernion &C)
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:60
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
void operator=(const septernion &)
Definition: septernionI.H:96
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
static const septernion I
Definition: septernion.H:83
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
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:61
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void operator/=(const quaternion &)
Definition: septernionI.H:138
volScalarField & C
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void operator+=(const vector &)
Definition: septernionI.H:115
vector invTransformPoint(const vector &v) const
Inverse Transform the given coordinate point.
Definition: septernionI.H:88
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
Definition: quaternion.C:55
Ostream & operator<<(Ostream &, const ensightPart &)
const vector & t() const
Definition: septernionI.H:58
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
const quaternion & r() const
Definition: septernionI.H:64
bool contiguous< septernion >()
Data associated with septernion type are contiguous.
Definition: septernion.H:179
vector transformPoint(const vector &v) const
Transform the given coordinate point.
Definition: septernionI.H:82
bool operator!=(const particle &, const particle &)
Definition: particle.C:1106
static const char *const typeName
Definition: septernion.H:80
Namespace for OpenFOAM.
static const septernion zero
Definition: septernion.H:82