/usr/include/opencollada/COLLADABaseUtils/Math/COLLADABUMathQuaternion.h is in opencollada-dev 0.1.0~20140703.ddf8f47+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | /*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of COLLADABaseUtils.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __COLLADABU_MATH_QUATERNION_H__
#define __COLLADABU_MATH_QUATERNION_H__
#include "COLLADABUMathPrerequisites.h"
namespace COLLADABU
{
namespace Math
{
class Matrix3;
class Vector3;
/** Implementation of a Quaternion, i.e. a rotation around an axis.
*/
class Quaternion
{
public:
inline Quaternion (
Real fW = 1.0,
Real fX = 0.0, Real fY = 0.0, Real fZ = 0.0 )
{
w = fW;
x = fX;
y = fY;
z = fZ;
}
inline Quaternion ( const Quaternion& rkQ )
{
w = rkQ.w;
x = rkQ.x;
y = rkQ.y;
z = rkQ.z;
}
/// Construct a quaternion from a rotation matrix
inline Quaternion( const Matrix3& rot )
{
this->fromRotationMatrix( rot );
}
/// Construct a quaternion from an angle/axis
inline Quaternion( const Real& rfAngle_radian, const Vector3& rkAxis )
{
this->fromAngleAxis( rfAngle_radian, rkAxis );
}
/// Construct a quaternion from 3 orthonormal local axes
inline Quaternion( const Vector3& xaxis, const Vector3& yaxis, const Vector3& zaxis )
{
this->fromAxes( xaxis, yaxis, zaxis );
}
/// Construct a quaternion from 3 orthonormal local axes
inline Quaternion( const Vector3* akAxis )
{
this->fromAxes( akAxis );
}
inline void setAllElements ( Real fW , Real fX , Real fY, Real fZ )
{
w = fW;
x = fX;
y = fY;
z = fZ;
}
void fromRotationMatrix ( const Matrix3& kRot );
void toRotationMatrix ( Matrix3& kRot ) const;
void fromAngleAxis ( const Real& rfAngle_radian, const Vector3& rkAxis );
void toAngleAxis ( Real& rfAngle_radian, Vector3& rkAxis ) const;
void fromAxes ( const Vector3* akAxis );
void fromAxes ( const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis );
void toAxes ( Vector3* akAxis ) const;
void toAxes ( Vector3& xAxis, Vector3& yAxis, Vector3& zAxis ) const;
/// Get the local x-axis
Vector3 xAxis( void ) const;
/// Get the local y-axis
Vector3 yAxis( void ) const;
/// Get the local z-axis
Vector3 zAxis( void ) const;
inline Quaternion& operator= ( const Quaternion& rkQ )
{
w = rkQ.w;
x = rkQ.x;
y = rkQ.y;
z = rkQ.z;
return *this;
}
Quaternion operator+ ( const Quaternion& rkQ ) const;
Quaternion operator- ( const Quaternion& rkQ ) const;
Quaternion operator* ( const Quaternion& rkQ ) const;
Quaternion operator* ( Real fScalar ) const;
friend Quaternion operator* ( Real fScalar,
const Quaternion& rkQ );
Quaternion operator- () const;
inline bool operator== ( const Quaternion& rhs ) const
{
return ( rhs.x == x ) && ( rhs.y == y ) &&
( rhs.z == z ) && ( rhs.w == w );
}
inline bool operator!= ( const Quaternion& rhs ) const
{
return !operator==( rhs );
}
// functions of a quaternion
Real dot ( const Quaternion& rkQ ) const; // dot product
Real norm () const; // squared-length
/// Normalises this quaternion, and returns the previous length
Real normalise( void );
Quaternion inverse () const; // apply to non-zero quaternion
Quaternion unitInverse () const; // apply to unit-length quaternion
Quaternion exp () const;
Quaternion log () const;
// rotation of a vector by a quaternion
Vector3 operator* ( const Vector3& rkVector ) const;
/// Calculate the local roll element (in radians) of this quaternion
Real getRoll( void ) const;
/// Calculate the local pitch element (in radians) of this quaternion
Real getPitch( void ) const;
/// Calculate the local yaw element (in radians) of this quaternion
Real getYaw( void ) const;
/// Equality with tolerance (tolerance is max angle difference)
bool equals( const Quaternion& rhs, const Real& tolerance_radian ) const;
// spherical linear interpolation
static Quaternion slerp ( Real fT, const Quaternion& rkP,
const Quaternion& rkQ, bool shortestPath = false );
static Quaternion slerpExtraSpins ( Real fT,
const Quaternion& rkP, const Quaternion& rkQ,
int iExtraSpins );
// setup for spherical quadratic interpolation
static void intermediate ( const Quaternion& rkQ0,
const Quaternion& rkQ1, const Quaternion& rkQ2,
Quaternion& rka, Quaternion& rkB );
// spherical quadratic interpolation
static Quaternion squad ( Real fT, const Quaternion& rkP,
const Quaternion& rkA, const Quaternion& rkB,
const Quaternion& rkQ, bool shortestPath = false );
// normalised linear interpolation - faster but less accurate (non-constant rotation velocity)
static Quaternion nlerp( Real fT, const Quaternion& rkP,
const Quaternion& rkQ, bool shortestPath = false );
// cutoff for sine near zero
static const Real ms_fEpsilon;
// special values
static const Quaternion ZERO;
static const Quaternion IDENTITY;
Real w, x, y, z;
};
}
}
#endif // __COLLADABU__MATH__QUATERNION_H__
|