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

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