libalmath  1.14.5
almath/types/alquaternion.h
00001 /*
00002  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
00003  * Use of this source code is governed by a BSD-style license that can be
00004  * found in the COPYING file.
00005  */
00006 
00007 
00008 #pragma once
00009 #ifndef _LIBALMATH_ALMATH_TYPES_ALQUATERNION_H_
00010 #define _LIBALMATH_ALMATH_TYPES_ALQUATERNION_H_
00011 
00012 #include <vector>
00013 
00014 namespace AL {
00015   namespace Math {
00016 
00023     struct Quaternion {
00025       float w;
00027       float x;
00029       float y;
00031       float z;
00032 
00035 
00050 
00051       Quaternion();
00052 
00055 
00070 
00071 
00072 
00073 
00074 
00075       Quaternion(
00076         float pW,
00077         float pX,
00078         float pY,
00079         float pZ);
00080 
00083 
00098 
00099 
00100 
00101 
00102 
00103       Quaternion(const std::vector<float>& pFloats);
00104 
00109       Quaternion& operator*= (const Quaternion& pQu2);
00110 
00115       Quaternion operator* (const Quaternion& pQua2) const;
00116 
00121       bool operator== (const Quaternion& pQua2) const;
00122 
00127       bool operator!= (const Quaternion& pQua2) const;
00128 
00133       Quaternion& operator*= (float pVal);
00134 
00139       Quaternion& operator/= (float pVal);
00140 
00152       bool isNear(
00153         const Quaternion& pQua2,
00154         const float&      pEpsilon=0.0001f) const;
00155 
00164       float norm() const;
00165 
00174       Quaternion normalize() const;
00175 
00183       Quaternion inverse() const;
00184 
00193       static Quaternion fromAngleAndAxisRotation(
00194         const float pAngle,
00195         const float pAxisX,
00196         const float pAxisY,
00197         const float pAxisZ);
00198 
00202       std::vector<float> toVector() const;
00203     };
00204 
00215     float norm(const Quaternion& pQua);
00216 
00227     Quaternion normalize(const Quaternion& pQua);
00228 
00229 
00237     void quaternionInverse(
00238       const Quaternion& pQua,
00239       Quaternion&       pQuaOut);
00240 
00250     Quaternion quaternionInverse(const Quaternion& pQua);
00251 
00252 
00265     Quaternion quaternionFromAngleAndAxisRotation(
00266       const float pAngle,
00267       const float pAxisX,
00268       const float pAxisY,
00269       const float pAxisZ);
00270 
00271 
00282     void angleAndAxisRotationFromQuaternion(
00283       const Quaternion& pQuaternion,
00284       float& pAngle,
00285       float& pAxisX,
00286       float& pAxisY,
00287       float& pAxisZ);
00288 
00289   } // end namespace math
00290 } // end namespace al
00291 #endif  // _LIBALMATH_ALMATH_TYPES_ALQUATERNION_H_
 All Classes Namespaces Functions Variables