quaternion: Added static member function to return a unit quaternion constructed from a vector

//- Return the unit quaternion (versor) from the given vector
    //  (w = sqrt(1 - |sqr(v)|))
    static inline quaternion unit(const vector& v);
This commit is contained in:
Henry Weller
2016-04-12 21:43:03 +01:00
parent 5e6bdeea57
commit 2d2ecf91dc
2 changed files with 13 additions and 2 deletions

View File

@ -140,12 +140,17 @@ public:
const bool normalized
);
//- Construct given scalar part, the vector part = vector::zero
//- Construct a real from the given scalar part, the vector part = zero
inline explicit quaternion(const scalar w);
//- Construct a pure quaternion given the vector part, scalar part = 0
//- Construct a pure imaginary quaternion given the vector part,
// the scalar part = 0
inline explicit quaternion(const vector& v);
//- Return the unit quaternion (versor) from the given vector
// (w = sqrt(1 - |sqr(v)|))
static inline quaternion unit(const vector& v);
//- Construct a quaternion given the three Euler angles
inline quaternion
(

View File

@ -78,6 +78,12 @@ inline Foam::quaternion::quaternion(const vector& v)
{}
inline Foam::quaternion Foam::quaternion::unit(const vector& v)
{
return quaternion(sqrt(1 - magSqr(v)), v);
}
inline Foam::quaternion::quaternion
(
const rotationSequence rs,