1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
28 inline Foam::septernion::septernion()
31 inline Foam::septernion::septernion(const vector& t, const quaternion& r)
37 inline Foam::septernion::septernion(const vector& t)
43 inline Foam::septernion::septernion(const quaternion& r)
50 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 inline const Foam::vector& Foam::septernion::t() const
58 inline const Foam::quaternion& Foam::septernion::r() const
64 inline Foam::vector& Foam::septernion::t()
70 inline Foam::quaternion& Foam::septernion::r()
76 inline Foam::vector Foam::septernion::transform(const vector& v) const
78 return t() + r().transform(v);
82 inline Foam::vector Foam::septernion::invTransform(const vector& v) const
84 return r().invTransform(v - t());
88 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
90 inline void Foam::septernion::operator=(const septernion& tr)
96 inline void Foam::septernion::operator*=(const septernion& tr)
98 t_ += r().transform(tr.t());
103 inline void Foam::septernion::operator=(const vector& t)
108 inline void Foam::septernion::operator+=(const vector& t)
113 inline void Foam::septernion::operator-=(const vector& t)
119 inline void Foam::septernion::operator=(const quaternion& r)
124 inline void Foam::septernion::operator*=(const quaternion& r)
129 inline void Foam::septernion::operator/=(const quaternion& r)
135 inline void Foam::septernion::operator*=(const scalar s)
141 inline void Foam::septernion::operator/=(const scalar s)
148 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
150 inline Foam::septernion Foam::inv(const septernion& tr)
152 return septernion(-tr.r().invTransform(tr.t()), conjugate(tr.r()));
156 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
158 inline bool Foam::operator==(const septernion& tr1, const septernion& tr2)
160 return (tr1.t() == tr2.t() && tr1.r() == tr2.r());
164 inline bool Foam::operator!=(const septernion& tr1, const septernion& tr2)
166 return !operator==(tr1, tr2);
170 inline Foam::septernion Foam::operator+
172 const septernion& tr,
176 return septernion(tr.t() + t, tr.r());
180 inline Foam::septernion Foam::operator+
186 return septernion(t + tr.t(), tr.r());
190 inline Foam::septernion Foam::operator+
192 const septernion& tr1,
193 const septernion& tr2
196 return septernion(tr1.t() + tr2.t(), tr1.r() + tr2.r());
200 inline Foam::septernion Foam::operator-
202 const septernion& tr,
206 return septernion(tr.t() - t, tr.r());
210 inline Foam::septernion Foam::operator-
212 const septernion& tr1,
213 const septernion& tr2
216 return septernion(tr1.t() - tr2.t(), tr1.r() - tr2.r());
220 inline Foam::septernion Foam::operator*
226 return septernion(tr.t(), r*tr.r());
230 inline Foam::septernion Foam::operator*
232 const septernion& tr,
236 return septernion(tr.t(), tr.r()*r);
240 inline Foam::septernion Foam::operator/
242 const septernion& tr,
246 return septernion(tr.t(), tr.r()/r);
250 inline Foam::septernion Foam::operator*
252 const septernion& tr1,
253 const septernion& tr2
258 tr1.t() + tr1.r().transform(tr2.t()),
259 tr1.r().transform(tr2.r())
264 inline Foam::septernion Foam::operator/
266 const septernion& tr1,
267 const septernion& tr2
274 inline Foam::septernion Foam::operator*(const scalar s, const septernion& tr)
276 return septernion(s*tr.t(), s*tr.r());
280 inline Foam::septernion Foam::operator*(const septernion& tr, const scalar s)
282 return septernion(s*tr.t(), s*tr.r());
286 inline Foam::septernion Foam::operator/(const septernion& tr, const scalar s)
288 return septernion(tr.t()/s, tr.r()/s);
292 // ************************************************************************* //