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-2013 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 "word.H"
47 #include "contiguous.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of friend functions and operators
55 
56 class septernion;
57 Istream& operator>>(Istream& is, septernion&);
58 Ostream& operator<<(Ostream& os, const septernion& C);
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class septernion Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class septernion
66 {
67  // private data
68 
69  //- Translation vector
70  vector t_;
71 
72  //- Rotation quaternion
73  quaternion r_;
74 
75 
76 public:
77 
78  // Static data members
79 
80  static const char* const typeName;
81 
82  static const septernion zero;
83  static const septernion I;
84 
85 
86  // Constructors
87 
88  //- Construct null
89  inline septernion();
90 
91  //- Construct given a translation vector and rotation quaternion
92  inline septernion(const vector& t, const quaternion& r);
93 
94  //- Construct a pure translation septernion given a translation vector
95  inline explicit septernion(const vector& t);
96 
97  //- Construct a pure rotation septernion given a rotation quaternion
98  inline explicit septernion(const quaternion& r);
99 
100  //- Construct from Istream
102 
103 
104  // Member functions
105 
106  // Access
107 
108  inline const vector& t() const;
109  inline const quaternion& r() const;
110 
111 
112  // Edit
113 
114  inline vector& t();
115  inline quaternion& r();
116 
117 
118  // Transform
119 
120  //- Transform the given vector
121  inline vector transform(const vector& v) const;
122 
123  //- Inverse Transform the given vector
124  inline vector invTransform(const vector& v) const;
125 
126 
127  // Member operators
128 
129  inline void operator=(const septernion&);
130  inline void operator*=(const septernion&);
131 
132  inline void operator=(const vector&);
133  inline void operator+=(const vector&);
134  inline void operator-=(const vector&);
135 
136  inline void operator=(const quaternion&);
137  inline void operator*=(const quaternion&);
138  inline void operator/=(const quaternion&);
139 
140  inline void operator*=(const scalar);
141  inline void operator/=(const scalar);
142 
143 
144  // IOstream operators
145 
146  friend Istream& operator>>(Istream& is, septernion&);
147  friend Ostream& operator<<(Ostream& os, const septernion& C);
148 };
149 
150 
151 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
152 
153 //- Return the inverse of the given septernion
154 inline septernion inv(const septernion& tr);
155 
156 
157 //- Return a string representation of a septernion
158 word name(const septernion&);
159 
160 //- Spherical linear interpolation of septernions. 0 for qa, 1 for qb
162 (
163  const septernion& qa,
164  const septernion& qb,
165  const scalar t
166 );
167 
168 //- Data associated with septernion type are contiguous
169 template<>
170 inline bool contiguous<septernion>() {return true;}
171 
172 
173 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
174 
175 inline bool operator==(const septernion& tr1, const septernion& tr2);
176 inline bool operator!=(const septernion& tr1, const septernion& tr2);
177 inline septernion operator+(const septernion& tr, const vector& t);
178 inline septernion operator+(const vector& t, const septernion& tr);
179 inline septernion operator-(const septernion& tr, const vector& t);
180 inline septernion operator*(const quaternion& r, const septernion& tr);
181 inline septernion operator*(const septernion& tr, const quaternion& r);
182 inline septernion operator/(const septernion& tr, const quaternion& r);
183 inline septernion operator*(const septernion& q1, const septernion& q2);
184 inline septernion operator/(const septernion& q1, const septernion& q2);
185 inline septernion operator*(const scalar s, const septernion& tr);
186 inline septernion operator*(const septernion& tr, const scalar s);
187 inline septernion operator/(const septernion& tr, const scalar s);
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #include "septernionI.H"
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 #endif
201 
202 // ************************************************************************* //
Foam::septernion::operator/=
void operator/=(const quaternion &)
Definition: septernionI.H:129
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::septernion
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:64
Foam::slerp
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
Definition: quaternion.C:55
quaternion.H
Foam::septernion::zero
static const septernion zero
Definition: septernion.H:81
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::septernion::operator<<
friend Ostream & operator<<(Ostream &os, const septernion &C)
C
volScalarField & C
Definition: readThermalProperties.H:104
Foam::quaternion
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:60
Foam::contiguous< septernion >
bool contiguous< septernion >()
Data associated with septernion type are contiguous.
Definition: septernion.H:169
Foam::septernion::operator*=
void operator*=(const septernion &)
Definition: septernionI.H:96
Foam::septernion::transform
vector transform(const vector &v) const
Transform the given vector.
Definition: septernionI.H:76
Foam::operator-
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
Foam::septernion::r_
quaternion r_
Rotation quaternion.
Definition: septernion.H:72
Foam::septernion::operator>>
friend Istream & operator>>(Istream &is, septernion &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:71
Foam::septernion::r
const quaternion & r() const
Definition: septernionI.H:58
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::septernion::operator-=
void operator-=(const vector &)
Definition: septernionI.H:113
Foam::operator!=
bool operator!=(const particle &, const particle &)
Definition: particle.C:147
Foam::septernion::operator=
void operator=(const septernion &)
Definition: septernionI.H:90
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
s
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))
Foam::operator*
tmp< fvMatrix< Type > > operator*(const DimensionedField< scalar, volMesh > &, const fvMatrix< Type > &)
Foam::operator/
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
Definition: dimensionedScalar.C:65
Foam::septernion::septernion
septernion()
Construct null.
Definition: septernionI.H:28
Foam::septernion::operator+=
void operator+=(const vector &)
Definition: septernionI.H:108
Foam::septernion::t
const vector & t() const
Definition: septernionI.H:52
Foam::Vector< scalar >
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::septernion::I
static const septernion I
Definition: septernion.H:82
vector.H
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:49
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
word.H
Foam::septernion::typeName
static const char *const typeName
Definition: septernion.H:79
Foam::septernion::invTransform
vector invTransform(const vector &v) const
Inverse Transform the given vector.
Definition: septernionI.H:82
Foam::C
Graphite solid properties.
Definition: C.H:57
Foam::operator+
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::septernion::t_
vector t_
Translation vector.
Definition: septernion.H:69
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
septernionI.H