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

septernion.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 Class
00026     Foam::septernion
00027 
00028 Description
00029     Septernion class used to perform translations and rotations in 3D space.
00030 
00031     It is composed of a translation vector and rotation quaternion and as
00032     such has seven components hence the name "septernion" from the Latin to
00033     be consistent with quaternion rather than "hepternion" derived from the
00034     Greek.
00035 
00036 SourceFiles
00037     septernionI.H
00038     septernion.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef septernion_H
00043 #define septernion_H
00044 
00045 #include "vector.H"
00046 #include "quaternion.H"
00047 #include "word.H"
00048 #include "contiguous.H"
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 namespace Foam
00053 {
00054 
00055 // Forward declaration of friend functions and operators
00056 
00057 class septernion;
00058 Istream& operator>>(Istream& is, septernion&);
00059 Ostream& operator<<(Ostream& os, const septernion& C);
00060 
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class septernion Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class septernion
00067 {
00068     // private data
00069 
00070         //- Translation vector
00071         vector t_;
00072 
00073         //- Rotation quaternion
00074         quaternion r_;
00075 
00076 
00077 public:
00078 
00079     // Static data members
00080 
00081         static const char* const typeName;
00082 
00083         static const septernion zero;
00084         static const septernion I;
00085 
00086 
00087     // Constructors
00088 
00089         //- Construct null
00090         inline septernion();
00091 
00092         //- Construct given a translation vector and rotation quaternion
00093         inline septernion(const vector& t, const quaternion& r);
00094 
00095         //- Construct a pure translation septernion given a translation vector
00096         inline explicit septernion(const vector& t);
00097 
00098         //- Construct a pure rotation septernion given a rotation quaternion
00099         inline explicit septernion(const quaternion& r);
00100 
00101         //- Construct from Istream
00102         septernion(Istream&);
00103 
00104 
00105     // Member functions
00106 
00107            // Access
00108 
00109                inline const vector& t() const;
00110                inline const quaternion& r() const;
00111 
00112 
00113            // Edit
00114 
00115                inline vector& t();
00116                inline quaternion& r();
00117 
00118 
00119            // Transform
00120 
00121                //- Transform the given vector 
00122                inline vector transform(const vector& v) const;
00123 
00124                //- Inverse Transform the given vector
00125                inline vector invTransform(const vector& v) const;
00126 
00127 
00128     // Member operators
00129 
00130         inline void operator=(const septernion&);
00131         inline void operator*=(const septernion&);
00132 
00133         inline void operator=(const vector&);
00134         inline void operator+=(const vector&);
00135         inline void operator-=(const vector&);
00136 
00137         inline void operator=(const quaternion&);
00138         inline void operator*=(const quaternion&);
00139         inline void operator/=(const quaternion&);
00140 
00141         inline void operator*=(const scalar);
00142         inline void operator/=(const scalar);
00143 
00144 
00145     // IOstream operators
00146 
00147         friend Istream& operator>>(Istream& is, septernion&);
00148         friend Ostream& operator<<(Ostream& os, const septernion& C);
00149 };
00150 
00151 
00152 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
00153 
00154 //- Return the inverse of the given septernion
00155 inline septernion inv(const septernion& tr);
00156 
00157 
00158 //- Return a string representation of a septernion
00159 word name(const septernion&);
00160 
00161 
00162 //- Data associated with septernion type are contiguous
00163 template<>
00164 inline bool contiguous<septernion>() {return true;}
00165 
00166 
00167 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
00168 
00169 inline bool operator==(const septernion& tr1, const septernion& tr2);
00170 inline bool operator!=(const septernion& tr1, const septernion& tr2);
00171 inline septernion operator+(const septernion& tr, const vector& t);
00172 inline septernion operator+(const vector& t, const septernion& tr);
00173 inline septernion operator-(const septernion& tr, const vector& t);
00174 inline septernion operator*(const quaternion& r, const septernion& tr);
00175 inline septernion operator*(const septernion& tr, const quaternion& r);
00176 inline septernion operator/(const septernion& tr, const quaternion& r);
00177 inline septernion operator*(const septernion& q1, const septernion& q2);
00178 inline septernion operator/(const septernion& q1, const septernion& q2);
00179 inline septernion operator*(const scalar s, const septernion& tr);
00180 inline septernion operator*(const septernion& tr, const scalar s);
00181 inline septernion operator/(const septernion& tr, const scalar s);
00182 
00183 
00184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00185 
00186 } // End namespace Foam
00187 
00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00189 
00190 #include "septernionI.H"
00191 
00192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00193 
00194 #endif
00195 
00196 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd