52             resQuat = *
this * resQuat;
 
   54             return Vec3( resQuat.
x, resQuat.
y, resQuat.
z );
 
   65                                     w * aQ.
y + 
y * aQ.
w + 
z * aQ.
x - 
x * aQ.
z,
 
   66                                     w * aQ.
z + 
z * aQ.
w + 
x * aQ.
y - 
y * aQ.
x ),
 
   67                               w * aQ.
w - 
x * aQ.
x - 
y * aQ.
y - 
z * aQ.
z );
 
   77             const float acceptableDelta = 0.00001f;
 
   79             return std::fabs(
x - q.
x) < acceptableDelta &&
 
   80                    std::fabs(
y - q.
y) < acceptableDelta &&
 
   81                    std::fabs(
z - q.
z) < acceptableDelta &&
 
   82                    std::fabs(
w - q.
w) < acceptableDelta;
 
  115             Vec3 orthonormal1, orthonormal2;
 
  116             FindOrthonormals( axis, orthonormal1, orthonormal2 );
 
  118             Vec3 transformed = *
this * orthonormal1;
 
  121             Vec3 flattened = transformed -  axis * 
Vec3::Dot( transformed, axis );
 
  125             return std::acos( Vec3::Dot( orthonormal1, flattened ) );
 
  134             const float scale = std::sqrt( 
x * 
x + 
y * 
y + 
z * 
z );
 
  136             if (std::fabs( scale ) < 0.00001f)
 
  138                 outAxis = 
Vec3( 0, 0, 0 );
 
  142                 outAxis.
x = 
x / scale;
 
  143                 outAxis.
y = 
y / scale;
 
  144                 outAxis.
z = z / scale;
 
  147             outAngleRad = std::acos( 
w ) * 2;
 
  154             const Vec3 xAxis( 1, 0, 0 );
 
  155             const Vec3 yAxis( 0, 1, 0 );
 
  156             const Vec3 zAxis( 0, 0, 1 );
 
  172             float angleRad = angleDeg * (3.1418693659f / 180.0f);
 
  176             const float sinAngle = std::sin( angleRad );
 
  178             x = axis.
x * sinAngle;
 
  179             y = axis.
y * sinAngle;
 
  180             z = axis.
z * sinAngle;
 
  181             w = std::cos( angleRad );
 
  198             const float trace = 1.0f + mat.m[0] + mat.m[5] + mat.m[10];
 
  202                 const float S = sqrtf( trace ) * 2.0f;
 
  203                 x = ( mat.m[9] - mat.m[6] ) / S;
 
  204                 y = ( mat.m[2] - mat.m[8] ) / S;
 
  205                 z = ( mat.m[4] - mat.m[1] ) / S;
 
  208             else if (mat.m[0] > mat.m[5] && mat.m[0] > mat.m[10])
 
  210                 const float S = std::sqrt( 1.0f + mat.m[0] - mat.m[5] - mat.m[10] ) * 2.0f;
 
  212                 y = (mat.m[4] + mat.m[1] ) / S;
 
  213                 z = (mat.m[2] + mat.m[8] ) / S;
 
  214                 w = (mat.m[9] - mat.m[6] ) / S;
 
  216             else if (mat.m[5] > mat.m[10])
 
  218                 const float S = std::sqrt( 1.0f + mat.m[5] - mat.m[0] - mat.m[10] ) * 2.0f;
 
  219                 x = (mat.m[4] + mat.m[1] ) / S;
 
  221                 z = (mat.m[9] + mat.m[6] ) / S;
 
  222                 w = (mat.m[2] - mat.m[8] ) / S;
 
  226                 const float S = std::sqrt( 1.0f + mat.m[10] - mat.m[0] - mat.m[5] ) * 2.0f;
 
  227                 x = (mat.m[2] + mat.m[8] ) / S;
 
  228                 y = (mat.m[9] + mat.m[6] ) / S;
 
  230                 w = (mat.m[4] - mat.m[1] ) / S;
 
  241             const float x2 = 
x * 
x;
 
  242             const float y2 = 
y * 
y;
 
  243             const float z2 = 
z * 
z;
 
  244             const float xy = x * 
y;
 
  245             const float xz = x * 
z;
 
  246             const float yz = y * 
z;
 
  247             const float wx = 
w * 
x;
 
  248             const float wy = 
w * 
y;
 
  249             const float wz = 
w * 
z;
 
  251             outMatrix.m[ 0] = 1 - 2 * (y2 + z2);
 
  252             outMatrix.m[ 1] = 2 * (xy - wz);
 
  253             outMatrix.m[ 2] = 2 * (xz + wy);
 
  255             outMatrix.m[ 4] = 2 * (xy + wz);
 
  256             outMatrix.m[ 5] = 1 - 2 * (x2 + z2);
 
  257             outMatrix.m[ 6] = 2 * (yz - wx);
 
  259             outMatrix.m[ 8] = 2 * (xz - wy);
 
  260             outMatrix.m[ 9] = 2 * (yz + wx);
 
  261             outMatrix.m[10] = 1 - 2 * (x2 + y2);
 
  276             out.
z = std::atan2( 2 * 
y * 
w - 2 * 
x * 
z, 1 - 2 * 
y * 
y - 2 * z * z );
 
  277             out.
y = std::asin( 2 * 
x * 
y + 2 * z * 
w );
 
  278             out.
x = std::atan2( 2 * 
x * w - 2 * 
y * z, 1 - 2 * 
x * 
x - 2 * z * z );
 
  279             return out / (3.14159265358979f / 180.0f);
 
  285             const float mag2 = 
w * 
w + 
x * 
x + 
y * 
y + 
z * 
z;
 
  286             const float acceptableDelta = 0.00001f;
 
  288             if (std::fabs( mag2 ) > acceptableDelta && std::fabs( mag2 - 1.0f ) > acceptableDelta)
 
  290                 const float oneOverMag = 1.0f / std::sqrt( mag2 );
 
  309         void FindOrthonormals( 
const Vec3& normal, 
Vec3& orthonormal1, 
Vec3& orthonormal2 )
 const 
  311             Matrix44 orthoX( 90,  0, 0 );
 
  312             Matrix44 orthoY(  0, 90, 0 );
 
  315             Matrix44::TransformDirection( normal, orthoX, &ww );
 
  316             const float dot = 
Vec3::Dot( normal, ww );
 
  318             if (std::fabs( dot ) > 0.6f)
 
  320                 Matrix44::TransformDirection( normal, orthoY, &ww );
 
  327             orthonormal2 = 
Vec3::Cross( normal, orthonormal1 );
 
Quaternion()
Constructor. 
Definition: Quaternion.hpp:14
 
void FromMatrix(const Matrix44 &mat)
Definition: Quaternion.hpp:196
 
float x
X coordinate. 
Definition: Vec3.hpp:15
 
Definition: AudioClip.hpp:4
 
static Quaternion FromEuler(const Vec3 &euler)
Definition: Quaternion.hpp:152
 
Quaternion operator*(const Quaternion &aQ) const 
Applies rotation aQ to this quaternion and returns the result. 
Definition: Quaternion.hpp:62
 
Vec3 GetEuler() const 
Definition: Quaternion.hpp:273
 
float z
Definition: Quaternion.hpp:304
 
3-component vector. 
Definition: Vec3.hpp:12
 
void GetMatrix(Matrix44 &outMatrix) const 
Definition: Quaternion.hpp:239
 
float y
Definition: Quaternion.hpp:302
 
bool operator==(const Quaternion &q) const 
Definition: Quaternion.hpp:75
 
static Quaternion CreateFromAxisAngle(const Vec3 &axis, float angleDeg)
Definition: Quaternion.hpp:188
 
float w
Definition: Quaternion.hpp:306
 
Quaternion Conjugate() const 
Definition: Quaternion.hpp:101
 
float x
Definition: Quaternion.hpp:300
 
float z
Z coordinate. 
Definition: Vec3.hpp:19
 
static Vec3 Cross(const Vec3 &v1, const Vec3 &v2)
Cross product. 
Definition: Vec3.hpp:28
 
void Normalize()
Definition: Quaternion.hpp:283
 
float FindTwist(const Vec3 &axis) const 
Finds twist angle around axis. 
Definition: Quaternion.hpp:112
 
static float Dot(const Vec3 &v1, const Vec3 &v2)
Definition: Vec3.hpp:100
 
void FromAxisAngle(const Vec3 &axis, float angleDeg)
Definition: Quaternion.hpp:170
 
void GetAxisAngle(Vec3 &outAxis, float &outAngleRad) const 
Definition: Quaternion.hpp:132
 
Vec3 Normalized() const 
Definition: Vec3.hpp:311
 
float y
Y coordinate. 
Definition: Vec3.hpp:17
 
Quaternion(const Vec3 &vec, float aW)
Definition: Quaternion.hpp:20
 
bool operator!=(const Quaternion &q) const 
Definition: Quaternion.hpp:90
 
Stores an orientation. 
Definition: Quaternion.hpp:11