1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 Septernion class used to perform translations and rotations in 3D space.
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
39 \*---------------------------------------------------------------------------*/
45 #include "quaternion.H"
47 #include "contiguous.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 // Forward declaration of friend functions and operators
57 Istream& operator>>(Istream& is, septernion&);
58 Ostream& operator<<(Ostream& os, const septernion& C);
61 /*---------------------------------------------------------------------------*\
62 Class septernion Declaration
63 \*---------------------------------------------------------------------------*/
69 //- Translation vector
72 //- Rotation quaternion
78 // Static data members
80 static const char* const typeName;
82 static const septernion zero;
83 static const septernion I;
91 //- Construct given a translation vector and rotation quaternion
92 inline septernion(const vector& t, const quaternion& r);
94 //- Construct a pure translation septernion given a translation vector
95 inline explicit septernion(const vector& t);
97 //- Construct a pure rotation septernion given a rotation quaternion
98 inline explicit septernion(const quaternion& r);
100 //- Construct from Istream
101 septernion(Istream&);
108 inline const vector& t() const;
109 inline const quaternion& r() const;
115 inline quaternion& r();
120 //- Transform the given vector
121 inline vector transform(const vector& v) const;
123 //- Inverse Transform the given vector
124 inline vector invTransform(const vector& v) const;
129 inline void operator=(const septernion&);
130 inline void operator*=(const septernion&);
132 inline void operator=(const vector&);
133 inline void operator+=(const vector&);
134 inline void operator-=(const vector&);
136 inline void operator=(const quaternion&);
137 inline void operator*=(const quaternion&);
138 inline void operator/=(const quaternion&);
140 inline void operator*=(const scalar);
141 inline void operator/=(const scalar);
144 // IOstream operators
146 friend Istream& operator>>(Istream& is, septernion&);
147 friend Ostream& operator<<(Ostream& os, const septernion& C);
151 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
153 //- Return the inverse of the given septernion
154 inline septernion inv(const septernion& tr);
157 //- Return a string representation of a septernion
158 word name(const septernion&);
161 //- Data associated with septernion type are contiguous
163 inline bool contiguous<septernion>() {return true;}
166 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
168 inline bool operator==(const septernion& tr1, const septernion& tr2);
169 inline bool operator!=(const septernion& tr1, const septernion& tr2);
170 inline septernion operator+(const septernion& tr, const vector& t);
171 inline septernion operator+(const vector& t, const septernion& tr);
172 inline septernion operator-(const septernion& tr, const vector& t);
173 inline septernion operator*(const quaternion& r, const septernion& tr);
174 inline septernion operator*(const septernion& tr, const quaternion& r);
175 inline septernion operator/(const septernion& tr, const quaternion& r);
176 inline septernion operator*(const septernion& q1, const septernion& q2);
177 inline septernion operator/(const septernion& q1, const septernion& q2);
178 inline septernion operator*(const scalar s, const septernion& tr);
179 inline septernion operator*(const septernion& tr, const scalar s);
180 inline septernion operator/(const septernion& tr, const scalar s);
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 #include "septernionI.H"
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 // ************************************************************************* //