1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Septernion class used to perform translations and rotations in 3D space.
31 It is composed of a translation vector and rotation quaternion and as
32 such has seven components hence the name "septernion" from the Latin to
33 be consistent with quaternion rather than "hepternion" derived from the
40 \*---------------------------------------------------------------------------*/
46 #include "quaternion.H"
48 #include "contiguous.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // Forward declaration of friend functions and operators
58 Istream& operator>>(Istream& is, septernion&);
59 Ostream& operator<<(Ostream& os, const septernion& C);
62 /*---------------------------------------------------------------------------*\
63 Class septernion Declaration
64 \*---------------------------------------------------------------------------*/
70 //- Translation vector
73 //- Rotation quaternion
79 // Static data members
81 static const char* const typeName;
83 static const septernion zero;
84 static const septernion I;
92 //- Construct given a translation vector and rotation quaternion
93 inline septernion(const vector& t, const quaternion& r);
95 //- Construct a pure translation septernion given a translation vector
96 inline explicit septernion(const vector& t);
98 //- Construct a pure rotation septernion given a rotation quaternion
99 inline explicit septernion(const quaternion& r);
101 //- Construct from Istream
102 septernion(Istream&);
109 inline const vector& t() const;
110 inline const quaternion& r() const;
116 inline quaternion& r();
121 //- Transform the given vector
122 inline vector transform(const vector& v) const;
124 //- Inverse Transform the given vector
125 inline vector invTransform(const vector& v) const;
130 inline void operator=(const septernion&);
131 inline void operator*=(const septernion&);
133 inline void operator=(const vector&);
134 inline void operator+=(const vector&);
135 inline void operator-=(const vector&);
137 inline void operator=(const quaternion&);
138 inline void operator*=(const quaternion&);
139 inline void operator/=(const quaternion&);
141 inline void operator*=(const scalar);
142 inline void operator/=(const scalar);
145 // IOstream operators
147 friend Istream& operator>>(Istream& is, septernion&);
148 friend Ostream& operator<<(Ostream& os, const septernion& C);
152 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
154 //- Return the inverse of the given septernion
155 inline septernion inv(const septernion& tr);
158 //- Return a string representation of a septernion
159 word name(const septernion&);
162 //- Data associated with septernion type are contiguous
164 inline bool contiguous<septernion>() {return true;}
167 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
169 inline bool operator==(const septernion& tr1, const septernion& tr2);
170 inline bool operator!=(const septernion& tr1, const septernion& tr2);
171 inline septernion operator+(const septernion& tr, const vector& t);
172 inline septernion operator+(const vector& t, const septernion& tr);
173 inline septernion operator-(const septernion& tr, const vector& t);
174 inline septernion operator*(const quaternion& r, const septernion& tr);
175 inline septernion operator*(const septernion& tr, const quaternion& r);
176 inline septernion operator/(const septernion& tr, const quaternion& r);
177 inline septernion operator*(const septernion& q1, const septernion& q2);
178 inline septernion operator/(const septernion& q1, const septernion& q2);
179 inline septernion operator*(const scalar s, const septernion& tr);
180 inline septernion operator*(const septernion& tr, const scalar s);
181 inline septernion operator/(const septernion& tr, const scalar s);
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 } // End namespace Foam
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 #include "septernionI.H"
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 // ************************************************************************* //