initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / septernion / septernion.H
blob906e68cf0056c839c4b44f737d40eeda19e74415
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM 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 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::septernion
28 Description
29     Septernion class used to perform translations and rotations in 3D space.
31     It is composed of a translation vector and rotation quaternion and as
32     such has seven components hence the name "septernion" from the Latin to
33     be consistent with quaternion rather than "hepternion" derived from the
34     Greek.
36 SourceFiles
37     septernionI.H
38     septernion.C
40 \*---------------------------------------------------------------------------*/
42 #ifndef septernion_H
43 #define septernion_H
45 #include "vector.H"
46 #include "quaternion.H"
47 #include "word.H"
48 #include "contiguous.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 // Forward declaration of friend functions and operators
57 class septernion;
58 Istream& operator>>(Istream& is, septernion&);
59 Ostream& operator<<(Ostream& os, const septernion& C);
62 /*---------------------------------------------------------------------------*\
63                            Class septernion Declaration
64 \*---------------------------------------------------------------------------*/
66 class septernion
68     // private data
70         //- Translation vector
71         vector t_;
73         //- Rotation quaternion
74         quaternion r_;
77 public:
79     // Static data members
81         static const char* const typeName;
83         static const septernion zero;
84         static const septernion I;
87     // Constructors
89         //- Construct null
90         inline septernion();
92         //- Construct given a translation vector and rotation quaternion
93         inline septernion(const vector& t, const quaternion& r);
95         //- Construct a pure translation septernion given a translation vector
96         inline explicit septernion(const vector& t);
98         //- Construct a pure rotation septernion given a rotation quaternion
99         inline explicit septernion(const quaternion& r);
101         //- Construct from Istream
102         septernion(Istream&);
105     // Member functions
107            // Access
109                inline const vector& t() const;
110                inline const quaternion& r() const;
113            // Edit
115                inline vector& t();
116                inline quaternion& r();
119            // Transform
121                //- Transform the given vector 
122                inline vector transform(const vector& v) const;
124                //- Inverse Transform the given vector
125                inline vector invTransform(const vector& v) const;
128     // Member operators
130         inline void operator=(const septernion&);
131         inline void operator*=(const septernion&);
133         inline void operator=(const vector&);
134         inline void operator+=(const vector&);
135         inline void operator-=(const vector&);
137         inline void operator=(const quaternion&);
138         inline void operator*=(const quaternion&);
139         inline void operator/=(const quaternion&);
141         inline void operator*=(const scalar);
142         inline void operator/=(const scalar);
145     // IOstream operators
147         friend Istream& operator>>(Istream& is, septernion&);
148         friend Ostream& operator<<(Ostream& os, const septernion& C);
152 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
154 //- Return the inverse of the given septernion
155 inline septernion inv(const septernion& tr);
158 //- Return a string representation of a septernion
159 word name(const septernion&);
162 //- Data associated with septernion type are contiguous
163 template<>
164 inline bool contiguous<septernion>() {return true;}
167 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
169 inline bool operator==(const septernion& tr1, const septernion& tr2);
170 inline bool operator!=(const septernion& tr1, const septernion& tr2);
171 inline septernion operator+(const septernion& tr, const vector& t);
172 inline septernion operator+(const vector& t, const septernion& tr);
173 inline septernion operator-(const septernion& tr, const vector& t);
174 inline septernion operator*(const quaternion& r, const septernion& tr);
175 inline septernion operator*(const septernion& tr, const quaternion& r);
176 inline septernion operator/(const septernion& tr, const quaternion& r);
177 inline septernion operator*(const septernion& q1, const septernion& q2);
178 inline septernion operator/(const septernion& q1, const septernion& q2);
179 inline septernion operator*(const scalar s, const septernion& tr);
180 inline septernion operator*(const septernion& tr, const scalar s);
181 inline septernion operator/(const septernion& tr, const scalar s);
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 } // End namespace Foam
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 #include "septernionI.H"
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 #endif
196 // ************************************************************************* //