septernion.C
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) 2011-2013 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "septernion.H"
27 #include "IOstreams.H"
28 #include "OStringStream.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 const char* const Foam::septernion::typeName = "septernion";
34 (
35  vector(0, 0, 0),
36  quaternion(0, vector(0, 0, 0))
37 );
39 (
40  vector(0, 0, 0),
41  quaternion(1, vector(0, 0, 0))
42 );
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 {
48  is >> *this;
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
55 {
56  OStringStream buf;
57  buf << '(' << s.t() << ',' << s.r() << ')';
58  return buf.str();
59 }
60 
61 
63 (
64  const septernion& qa,
65  const septernion& qb,
66  const scalar t
67 )
68 {
69  return septernion((1.0-t)*qa.t()+t*qb.t(), slerp(qa.r(), qb.r(), t));
70 }
71 
72 
73 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
74 
76 {
77  // Read beginning of septernion
78  is.readBegin("septernion");
79 
80  is >> s.t() >> s.r();
81 
82  // Read end of septernion
83  is.readEnd("septernion");
84 
85  // Check state of Istream
86  is.check("operator>>(Istream&, septernion&)");
87 
88  return is;
89 }
90 
91 
93 {
94  os << token::BEGIN_LIST
95  << s.t() << token::SPACE << s.r()
96  << token::END_LIST;
97 
98  return os;
99 }
100 
101 
102 // ************************************************************************* //
Foam::Istream::readEnd
Istream & readEnd(const char *funcName)
Definition: Istream.C:105
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::septernion
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:64
Foam::slerp
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.
Definition: quaternion.C:55
Foam::septernion::zero
static const septernion zero
Definition: septernion.H:81
Foam::OStringStream::str
string str() const
Return the string.
Definition: OStringStream.H:107
septernion.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::septernion::r
const quaternion & r() const
Definition: septernionI.H:58
OStringStream.H
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::septernion::septernion
septernion()
Construct null.
Definition: septernionI.H:28
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
Foam::septernion::t
const vector & t() const
Definition: septernionI.H:52
Foam::OStringStream
Output to memory buffer stream.
Definition: OStringStream.H:49
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::septernion::I
static const septernion I
Definition: septernion.H:82
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Istream::readBegin
Istream & readBegin(const char *funcName)
Definition: Istream.C:88
Foam::septernion::typeName
static const char *const typeName
Definition: septernion.H:79
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
Foam::token::SPACE
@ SPACE
Definition: token.H:95