mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: adjust comments in quaternion
- make I/O operators global (non-member)
This commit is contained in:
committed by
Andrew Heather
parent
661d1f53df
commit
5f40a738d3
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -153,12 +153,8 @@ Foam::quaternion Foam::pow(const quaternion& q, const scalar power)
|
|||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, quaternion& q)
|
Foam::Istream& Foam::operator>>(Istream& is, quaternion& q)
|
||||||
{
|
{
|
||||||
// Read beginning of quaternion
|
|
||||||
is.readBegin("quaternion");
|
is.readBegin("quaternion");
|
||||||
|
|
||||||
is >> q.w() >> q.v();
|
is >> q.w() >> q.v();
|
||||||
|
|
||||||
// Read end of quaternion
|
|
||||||
is.readEnd("quaternion");
|
is.readEnd("quaternion");
|
||||||
|
|
||||||
is.check(FUNCTION_NAME);
|
is.check(FUNCTION_NAME);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -49,20 +49,13 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
|
|
||||||
class quaternion;
|
|
||||||
Istream& operator>>(Istream& is, quaternion&);
|
|
||||||
Ostream& operator<<(Ostream& os, const quaternion& C);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class quaternion Declaration
|
Class quaternion Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class quaternion
|
class quaternion
|
||||||
{
|
{
|
||||||
// private data
|
// Private Data
|
||||||
|
|
||||||
//- Scalar part of the quaternion ( = cos(theta/2) for rotation)
|
//- Scalar part of the quaternion ( = cos(theta/2) for rotation)
|
||||||
scalar w_;
|
scalar w_;
|
||||||
@ -107,13 +100,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Member constants
|
// Member Constants
|
||||||
|
|
||||||
//- Rank of quaternion is 1
|
//- Rank of quaternion is 1
|
||||||
static constexpr direction rank = 1;
|
static constexpr direction rank = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static Data Members
|
||||||
|
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
|
|
||||||
@ -134,7 +127,7 @@ public:
|
|||||||
inline quaternion(const vector& d, const scalar theta);
|
inline quaternion(const vector& d, const scalar theta);
|
||||||
|
|
||||||
//- Construct a rotation quaternion given the direction d
|
//- Construct a rotation quaternion given the direction d
|
||||||
// and cosine angle cosTheta and a if d is normalized
|
//- and cosine angle cosTheta and a if d is normalized
|
||||||
inline quaternion
|
inline quaternion
|
||||||
(
|
(
|
||||||
const vector& d,
|
const vector& d,
|
||||||
@ -146,93 +139,87 @@ public:
|
|||||||
inline explicit quaternion(const scalar w);
|
inline explicit quaternion(const scalar w);
|
||||||
|
|
||||||
//- Construct a pure imaginary quaternion given the vector part,
|
//- Construct a pure imaginary quaternion given the vector part,
|
||||||
// the scalar part = 0
|
//- the scalar part = 0
|
||||||
inline explicit quaternion(const vector& v);
|
inline explicit quaternion(const vector& v);
|
||||||
|
|
||||||
//- Return the unit quaternion (versor) from the given vector
|
//- Return the unit quaternion (versor) from the given vector
|
||||||
// (w = sqrt(1 - |sqr(v)|))
|
//- (w = sqrt(1 - |sqr(v)|))
|
||||||
static inline quaternion unit(const vector& v);
|
static inline quaternion unit(const vector& v);
|
||||||
|
|
||||||
//- Construct a quaternion given the three Euler angles
|
//- Construct from three Euler angles
|
||||||
inline quaternion
|
inline quaternion(const rotationSequence rs, const vector& angles);
|
||||||
(
|
|
||||||
const rotationSequence rs,
|
|
||||||
const vector& angles
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct a quaternion from a rotation tensor
|
//- Construct from a rotation tensor
|
||||||
inline explicit quaternion(const tensor& rotationTensor);
|
inline explicit quaternion(const tensor& rotationTensor);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
quaternion(Istream&);
|
explicit quaternion(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Scalar part of the quaternion ( = cos(theta/2) for rotation)
|
//- Scalar part of the quaternion ( = cos(theta/2) for rotation)
|
||||||
inline scalar w() const;
|
inline scalar w() const;
|
||||||
|
|
||||||
//- Vector part of the quaternion ( = axis of rotation)
|
//- Vector part of the quaternion ( = axis of rotation)
|
||||||
inline const vector& v() const;
|
inline const vector& v() const;
|
||||||
|
|
||||||
//- The rotation tensor corresponding the quaternion
|
//- The rotation tensor corresponding the quaternion
|
||||||
inline tensor R() const;
|
inline tensor R() const;
|
||||||
|
|
||||||
//- Return a vector of euler angles corresponding to the
|
//- Return a vector of euler angles corresponding to the
|
||||||
// specified rotation sequence
|
//- specified rotation sequence
|
||||||
inline vector eulerAngles(const rotationSequence rs) const;
|
inline vector eulerAngles(const rotationSequence rs) const;
|
||||||
|
|
||||||
inline quaternion normalized() const;
|
//- Return the quaternion normalized by its magnitude
|
||||||
|
inline quaternion normalized() const;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Scalar part of the quaternion ( = cos(theta/2) for rotation)
|
//- Scalar part of the quaternion ( = cos(theta/2) for rotation)
|
||||||
inline scalar& w();
|
inline scalar& w();
|
||||||
|
|
||||||
//- Vector part of the quaternion ( = axis of rotation)
|
//- Vector part of the quaternion ( = axis of rotation)
|
||||||
inline vector& v();
|
inline vector& v();
|
||||||
|
|
||||||
inline void normalize();
|
//- Normalize the quaternion by its magnitude
|
||||||
|
inline void normalize();
|
||||||
|
|
||||||
|
|
||||||
// Transform
|
// Transform
|
||||||
|
|
||||||
//- Rotate the given vector
|
//- Rotate the given vector
|
||||||
inline vector transform(const vector& v) const;
|
inline vector transform(const vector& v) const;
|
||||||
|
|
||||||
//- Rotate the given vector anti-clockwise
|
//- Rotate the given vector anti-clockwise
|
||||||
inline vector invTransform(const vector& v) const;
|
inline vector invTransform(const vector& v) const;
|
||||||
|
|
||||||
//- Rotate the given quaternion (and normalize)
|
//- Rotate the given quaternion (and normalize)
|
||||||
inline quaternion transform(const quaternion& q) const;
|
inline quaternion transform(const quaternion& q) const;
|
||||||
|
|
||||||
//- Rotate the given quaternion anti-clockwise (and normalize)
|
//- Rotate the given quaternion anti-clockwise (and normalize)
|
||||||
inline quaternion invTransform(const quaternion& q) const;
|
inline quaternion invTransform(const quaternion& q) const;
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member Operators
|
||||||
|
|
||||||
inline void operator=(const quaternion&);
|
inline void operator=(const quaternion& q);
|
||||||
inline void operator+=(const quaternion&);
|
inline void operator+=(const quaternion& q);
|
||||||
inline void operator-=(const quaternion&);
|
inline void operator-=(const quaternion& q);
|
||||||
inline void operator*=(const quaternion&);
|
inline void operator*=(const quaternion& q);
|
||||||
inline void operator/=(const quaternion&);
|
inline void operator/=(const quaternion& q);
|
||||||
|
|
||||||
inline void operator=(const scalar);
|
//- Change scalar portion
|
||||||
|
inline void operator=(const scalar s);
|
||||||
|
|
||||||
inline void operator=(const vector&);
|
//- Change vector portion
|
||||||
|
inline void operator=(const vector& v);
|
||||||
|
|
||||||
inline void operator*=(const scalar);
|
inline void operator*=(const scalar s);
|
||||||
inline void operator/=(const scalar);
|
inline void operator/=(const scalar s);
|
||||||
|
|
||||||
|
|
||||||
// IOstream operators
|
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, quaternion&);
|
|
||||||
friend Ostream& operator<<(Ostream& os, const quaternion& C);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -284,6 +271,9 @@ inline bool contiguous<quaternion>() {return true;}
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Istream& operator>>(Istream& is, quaternion& q);
|
||||||
|
Ostream& operator<<(Ostream& os, const quaternion& q);
|
||||||
|
|
||||||
inline bool operator==(const quaternion& q1, const quaternion& q2);
|
inline bool operator==(const quaternion& q1, const quaternion& q2);
|
||||||
inline bool operator!=(const quaternion& q1, const quaternion& q2);
|
inline bool operator!=(const quaternion& q1, const quaternion& q2);
|
||||||
inline quaternion operator+(const quaternion& q1, const quaternion& q2);
|
inline quaternion operator+(const quaternion& q1, const quaternion& q2);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
|||||||
Reference in New Issue
Block a user