FreeFOAM The Cross-Platform CFD Toolkit
septernion.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::septernion
26 
27 Description
28  Septernion class used to perform translations and rotations in 3D space.
29 
30  It is composed of a translation vector and rotation quaternion and as
31  such has seven components hence the name "septernion" from the Latin to
32  be consistent with quaternion rather than "hepternion" derived from the
33  Greek.
34 
35 SourceFiles
36  septernionI.H
37  septernion.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef septernion_H
42 #define septernion_H
43 
44 #include <OpenFOAM/vector.H>
45 #include <OpenFOAM/quaternion.H>
46 #include <OpenFOAM/word.H>
47 #include <OpenFOAM/contiguous.H>
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of friend functions and operators
55 
56 class septernion;
57 Istream& operator>>(Istream& is, septernion&);
58 Ostream& operator<<(Ostream& os, const septernion& C);
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class septernion Declaration
63 \*---------------------------------------------------------------------------*/
64 
66 {
67  // private data
68 
69  //- Translation vector
70  vector t_;
71 
72  //- Rotation quaternion
73  quaternion r_;
74 
75 
76 public:
77 
78  // Static data members
79 
80  static const char* const typeName;
81 
82  static const septernion zero;
83  static const septernion I;
84 
85 
86  // Constructors
87 
88  //- Construct null
89  inline septernion();
90 
91  //- Construct given a translation vector and rotation quaternion
92  inline septernion(const vector& t, const quaternion& r);
93 
94  //- Construct a pure translation septernion given a translation vector
95  inline explicit septernion(const vector& t);
96 
97  //- Construct a pure rotation septernion given a rotation quaternion
98  inline explicit septernion(const quaternion& r);
99 
100  //- Construct from Istream
102 
103 
104  // Member functions
105 
106  // Access
107 
108  inline const vector& t() const;
109  inline const quaternion& r() const;
110 
111 
112  // Edit
113 
114  inline vector& t();
115  inline quaternion& r();
116 
117 
118  // Transform
119 
120  //- Transform the given vector
121  inline vector transform(const vector& v) const;
122 
123  //- Inverse Transform the given vector
124  inline vector invTransform(const vector& v) const;
125 
126 
127  // Member operators
128 
129  inline void operator=(const septernion&);
130  inline void operator*=(const septernion&);
131 
132  inline void operator=(const vector&);
133  inline void operator+=(const vector&);
134  inline void operator-=(const vector&);
135 
136  inline void operator=(const quaternion&);
137  inline void operator*=(const quaternion&);
138  inline void operator/=(const quaternion&);
139 
140  inline void operator*=(const scalar);
141  inline void operator/=(const scalar);
142 
143 
144  // IOstream operators
145 
146  friend Istream& operator>>(Istream& is, septernion&);
147  friend Ostream& operator<<(Ostream& os, const septernion& C);
148 };
149 
150 
151 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
152 
153 //- Return the inverse of the given septernion
154 inline septernion inv(const septernion& tr);
155 
156 
157 //- Return a string representation of a septernion
158 word name(const septernion&);
159 
160 
161 //- Data associated with septernion type are contiguous
162 template<>
163 inline bool contiguous<septernion>() {return true;}
164 
165 
166 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
167 
168 inline bool operator==(const septernion& tr1, const septernion& tr2);
169 inline bool operator!=(const septernion& tr1, const septernion& tr2);
170 inline septernion operator+(const septernion& tr, const vector& t);
171 inline septernion operator+(const vector& t, const septernion& tr);
172 inline septernion operator-(const septernion& tr, const vector& t);
173 inline septernion operator*(const quaternion& r, const septernion& tr);
174 inline septernion operator*(const septernion& tr, const quaternion& r);
175 inline septernion operator/(const septernion& tr, const quaternion& r);
176 inline septernion operator*(const septernion& q1, const septernion& q2);
177 inline septernion operator/(const septernion& q1, const septernion& q2);
178 inline septernion operator*(const scalar s, const septernion& tr);
179 inline septernion operator*(const septernion& tr, const scalar s);
180 inline septernion operator/(const septernion& tr, const scalar s);
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #include <OpenFOAM/septernionI.H>
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************ vim: set sw=4 sts=4 et: ************************ //