FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00027 
00028 inline Foam::septernion::septernion()
00029 {}
00030 
00031 inline Foam::septernion::septernion(const vector& t, const quaternion& r)
00032 :
00033     t_(t),
00034     r_(r)
00035 {}
00036 
00037 inline Foam::septernion::septernion(const vector& t)
00038 :
00039     t_(t),
00040     r_(quaternion::I)
00041 {}
00042 
00043 inline Foam::septernion::septernion(const quaternion& r)
00044 :
00045     t_(vector::zero),
00046     r_(r)
00047 {}
00048 
00049 
00050 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00051 
00052 inline const Foam::vector& Foam::septernion::t() const
00053 {
00054     return t_;
00055 }
00056 
00057 
00058 inline const Foam::quaternion& Foam::septernion::r() const
00059 {
00060     return r_;
00061 }
00062 
00063 
00064 inline Foam::vector& Foam::septernion::t()
00065 {
00066     return t_;
00067 }
00068 
00069 
00070 inline Foam::quaternion& Foam::septernion::r()
00071 {
00072     return r_;
00073 }
00074 
00075 
00076 inline Foam::vector Foam::septernion::transform(const vector& v) const
00077 {
00078     return t() + r().transform(v);
00079 }
00080 
00081 
00082 inline Foam::vector Foam::septernion::invTransform(const vector& v) const
00083 {
00084     return r().invTransform(v - t());
00085 }
00086 
00087 
00088 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00089 
00090 inline void Foam::septernion::operator=(const septernion& tr)
00091 {
00092     t_ = tr.t_;
00093     r_ = tr.r_;
00094 }
00095 
00096 inline void Foam::septernion::operator*=(const septernion& tr)
00097 {
00098     t_ += r().transform(tr.t());
00099     r_ *= tr.r();
00100 }
00101 
00102 
00103 inline void Foam::septernion::operator=(const vector& t)
00104 {
00105     t_ = t;
00106 }
00107 
00108 inline void Foam::septernion::operator+=(const vector& t)
00109 {
00110     t_ += t;
00111 }
00112 
00113 inline void Foam::septernion::operator-=(const vector& t)
00114 {
00115     t_ -= t;
00116 }
00117 
00118 
00119 inline void Foam::septernion::operator=(const quaternion& r)
00120 {
00121     r_ = r;
00122 }
00123 
00124 inline void Foam::septernion::operator*=(const quaternion& r)
00125 {
00126     r_ *= r;
00127 }
00128 
00129 inline void Foam::septernion::operator/=(const quaternion& r)
00130 {
00131     r_ /= r;
00132 }
00133 
00134 
00135 inline void Foam::septernion::operator*=(const scalar s)
00136 {
00137     t_ *= s;
00138     r_ *= s;
00139 }
00140 
00141 inline void Foam::septernion::operator/=(const scalar s)
00142 {
00143     t_ /= s;
00144     r_ /= s;
00145 }
00146 
00147 
00148 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
00149 
00150 inline Foam::septernion Foam::inv(const septernion& tr)
00151 {
00152     return septernion(-tr.r().invTransform(tr.t()), conjugate(tr.r()));
00153 }
00154 
00155 
00156 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
00157 
00158 inline bool Foam::operator==(const septernion& tr1, const septernion& tr2)
00159 {
00160     return (tr1.t() == tr2.t() && tr1.r() == tr2.r());
00161 }
00162 
00163 
00164 inline bool Foam::operator!=(const septernion& tr1, const septernion& tr2)
00165 {
00166     return !operator==(tr1, tr2);
00167 }
00168 
00169 
00170 inline Foam::septernion Foam::operator+
00171 (
00172     const septernion& tr,
00173     const vector& t
00174 )
00175 {
00176     return septernion(tr.t() + t, tr.r());
00177 }
00178 
00179 
00180 inline Foam::septernion Foam::operator+
00181 (
00182     const vector& t,
00183     const septernion& tr
00184 )
00185 {
00186     return septernion(t + tr.t(), tr.r());
00187 }
00188 
00189 
00190 inline Foam::septernion Foam::operator-
00191 (
00192     const septernion& tr,
00193     const vector& t
00194 )
00195 {
00196     return septernion(tr.t() - t, tr.r());
00197 }
00198 
00199 
00200 inline Foam::septernion Foam::operator*
00201 (
00202     const quaternion& r,
00203     const septernion& tr
00204 )
00205 {
00206     return septernion(tr.t(), r*tr.r());
00207 }
00208 
00209 
00210 inline Foam::septernion Foam::operator*
00211 (
00212     const septernion& tr,
00213     const quaternion& r
00214 )
00215 {
00216     return septernion(tr.t(), tr.r()*r);
00217 }
00218 
00219 
00220 inline Foam::septernion Foam::operator/
00221 (
00222     const septernion& tr,
00223     const quaternion& r
00224 )
00225 {
00226     return septernion(tr.t(), tr.r()/r);
00227 }
00228 
00229 
00230 inline Foam::septernion Foam::operator*
00231 (
00232     const septernion& tr1,
00233     const septernion& tr2
00234 )
00235 {
00236     return septernion
00237     (
00238         tr1.t() + tr1.r().transform(tr2.t()),
00239         tr1.r().transform(tr2.r())
00240     );
00241 }
00242 
00243 
00244 inline Foam::septernion Foam::operator/
00245 (
00246     const septernion& tr1,
00247     const septernion& tr2
00248 )
00249 {
00250     return tr1*inv(tr2);
00251 }
00252 
00253 
00254 inline Foam::septernion Foam::operator*(const scalar s, const septernion& tr)
00255 {
00256     return septernion(s*tr.t(), s*tr.r());
00257 }
00258 
00259 
00260 inline Foam::septernion Foam::operator*(const septernion& tr, const scalar s)
00261 {
00262     return septernion(s*tr.t(), s*tr.r());
00263 }
00264 
00265 
00266 inline Foam::septernion Foam::operator/(const septernion& tr, const scalar s)
00267 {
00268     return septernion(tr.t()/s, tr.r()/s);
00269 }
00270 
00271 
00272 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines