OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

septernionI.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00028 
00029 inline Foam::septernion::septernion()
00030 {}
00031 
00032 inline Foam::septernion::septernion(const vector& t, const quaternion& r)
00033 :
00034     t_(t),
00035     r_(r)
00036 {}
00037 
00038 inline Foam::septernion::septernion(const vector& t)
00039 :
00040     t_(t),
00041     r_(quaternion::I)
00042 {}
00043 
00044 inline Foam::septernion::septernion(const quaternion& r)
00045 :
00046     t_(vector::zero),
00047     r_(r)
00048 {}
00049 
00050 
00051 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00052 
00053 inline const Foam::vector& Foam::septernion::t() const
00054 {
00055     return t_;
00056 }
00057 
00058 
00059 inline const Foam::quaternion& Foam::septernion::r() const
00060 {
00061     return r_;
00062 }
00063 
00064 
00065 inline Foam::vector& Foam::septernion::t()
00066 {
00067     return t_;
00068 }
00069 
00070 
00071 inline Foam::quaternion& Foam::septernion::r()
00072 {
00073     return r_;
00074 }
00075 
00076 
00077 inline Foam::vector Foam::septernion::transform(const vector& v) const
00078 {
00079     return t() + r().transform(v);
00080 }
00081 
00082 
00083 inline Foam::vector Foam::septernion::invTransform(const vector& v) const
00084 {
00085     return r().invTransform(v - t());
00086 }
00087 
00088 
00089 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00090 
00091 inline void Foam::septernion::operator=(const septernion& tr)
00092 {
00093     t_ = tr.t_;
00094     r_ = tr.r_;
00095 }
00096 
00097 inline void Foam::septernion::operator*=(const septernion& tr)
00098 {
00099     t_ += r().transform(tr.t());
00100     r_ *= tr.r();
00101 }
00102 
00103 
00104 inline void Foam::septernion::operator=(const vector& t)
00105 {
00106     t_ = t;
00107 }
00108 
00109 inline void Foam::septernion::operator+=(const vector& t)
00110 {
00111     t_ += t;
00112 }
00113 
00114 inline void Foam::septernion::operator-=(const vector& t)
00115 {
00116     t_ -= t;
00117 }
00118 
00119 
00120 inline void Foam::septernion::operator=(const quaternion& r)
00121 {
00122     r_ = r;
00123 }
00124 
00125 inline void Foam::septernion::operator*=(const quaternion& r)
00126 {
00127     r_ *= r;
00128 }
00129 
00130 inline void Foam::septernion::operator/=(const quaternion& r)
00131 {
00132     r_ /= r;
00133 }
00134 
00135 
00136 inline void Foam::septernion::operator*=(const scalar s)
00137 {
00138     t_ *= s;
00139     r_ *= s;
00140 }
00141 
00142 inline void Foam::septernion::operator/=(const scalar s)
00143 {
00144     t_ /= s;
00145     r_ /= s;
00146 }
00147 
00148 
00149 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
00150 
00151 inline Foam::septernion Foam::inv(const septernion& tr)
00152 {
00153     return septernion(-tr.r().invTransform(tr.t()), conjugate(tr.r()));
00154 }
00155 
00156 
00157 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
00158 
00159 inline bool Foam::operator==(const septernion& tr1, const septernion& tr2)
00160 {
00161     return (tr1.t() == tr2.t() && tr1.r() == tr2.r());
00162 }
00163 
00164 
00165 inline bool Foam::operator!=(const septernion& tr1, const septernion& tr2)
00166 {
00167     return !operator==(tr1, tr2);
00168 }
00169 
00170 
00171 inline Foam::septernion Foam::operator+
00172 (
00173     const septernion& tr,
00174     const vector& t
00175 )
00176 {
00177     return septernion(tr.t() + t, tr.r());
00178 }
00179 
00180 
00181 inline Foam::septernion Foam::operator+
00182 (
00183     const vector& t,
00184     const septernion& tr
00185 )
00186 {
00187     return septernion(t + tr.t(), tr.r());
00188 }
00189 
00190 
00191 inline Foam::septernion Foam::operator-
00192 (
00193     const septernion& tr,
00194     const vector& t
00195 )
00196 {
00197     return septernion(tr.t() - t, tr.r());
00198 }
00199 
00200 
00201 inline Foam::septernion Foam::operator*
00202 (
00203     const quaternion& r,
00204     const septernion& tr
00205 )
00206 {
00207     return septernion(tr.t(), r*tr.r());
00208 }
00209 
00210 
00211 inline Foam::septernion Foam::operator*
00212 (
00213     const septernion& tr,
00214     const quaternion& r
00215 )
00216 {
00217     return septernion(tr.t(), tr.r()*r);
00218 }
00219 
00220 
00221 inline Foam::septernion Foam::operator/
00222 (
00223     const septernion& tr,
00224     const quaternion& r
00225 )
00226 {
00227     return septernion(tr.t(), tr.r()/r);
00228 }
00229 
00230 
00231 inline Foam::septernion Foam::operator*
00232 (
00233     const septernion& tr1,
00234     const septernion& tr2
00235 )
00236 {
00237     return septernion
00238     (
00239         tr1.t() + tr1.r().transform(tr2.t()),
00240         tr1.r().transform(tr2.r())
00241     );
00242 }
00243 
00244 
00245 inline Foam::septernion Foam::operator/
00246 (
00247     const septernion& tr1,
00248     const septernion& tr2
00249 )
00250 {
00251     return tr1*inv(tr2);
00252 }
00253 
00254 
00255 inline Foam::septernion Foam::operator*(const scalar s, const septernion& tr)
00256 {
00257     return septernion(s*tr.t(), s*tr.r());
00258 }
00259 
00260 
00261 inline Foam::septernion Foam::operator*(const septernion& tr, const scalar s)
00262 {
00263     return septernion(s*tr.t(), s*tr.r());
00264 }
00265 
00266 
00267 inline Foam::septernion Foam::operator/(const septernion& tr, const scalar s)
00268 {
00269     return septernion(tr.t()/s, tr.r()/s);
00270 }
00271 
00272 
00273 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd