- Aldebaran documentation |
- C++ Libraries |
- index

libalmath 2.8.7.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alquaternion.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the COPYING file.
5 */
6
7
8 #pragma once
9 #ifndef _LIBALMATH_ALMATH_TYPES_ALQUATERNION_H_
10 #define _LIBALMATH_ALMATH_TYPES_ALQUATERNION_H_
11
12 #include <vector>
13 #include <almath/api.h>
14
15 namespace AL {
16 namespace Math {
17
24 struct ALMATH_API Quaternion {
26 float w;
28 float x;
30 float y;
32 float z;
33
36
51 Quaternion();
53
56
71 Quaternion(
77 float pW,
78 float pX,
79 float pY,
80 float pZ);
81
84
99 Quaternion(const std::vector<float>& pFloats);
105
110 Quaternion& operator*= (const Quaternion& pQua2);
111
116 inline Quaternion operator* (const Quaternion& pQua2) const
117 {
118 return Quaternion(
119 w*pQua2.w - x*pQua2.x - y*pQua2.y - z*pQua2.z,
120 w*pQua2.x + pQua2.w*x + y*pQua2.z - z*pQua2.y,
121 w*pQua2.y + pQua2.w*y + z*pQua2.x - x*pQua2.z,
122 w*pQua2.z + pQua2.w*z + x*pQua2.y - y*pQua2.x);
123 }
124
129 bool operator== (const Quaternion& pQua2) const;
130
135 bool operator!= (const Quaternion& pQua2) const;
136
141 inline Quaternion operator* (float pVal) const
142 {
143 return Quaternion(w*pVal, x*pVal, y*pVal, z*pVal);
144 }
145
150 Quaternion operator/ (float pVal) const;
151
156 Quaternion& operator*= (float pVal);
157
162 Quaternion& operator/= (float pVal);
163
175 bool isNear(
176 const Quaternion& pQua2,
177 const float& pEpsilon=0.0001f) const;
178
187 float norm() const;
188
197 Quaternion normalize() const;
198
206 Quaternion inverse() const;
207
216 static Quaternion fromAngleAndAxisRotation(
217 const float pAngle,
218 const float pAxisX,
219 const float pAxisY,
220 const float pAxisZ);
221
225 void toVector(std::vector<float>& pReturnVector) const;
226 std::vector<float> toVector(void) const;
227 };
228
239 ALMATH_API float norm(const Quaternion& pQua);
240
251 ALMATH_API Quaternion normalize(const Quaternion& pQua);
252
253
261 ALMATH_API void quaternionInverse(
262 const Quaternion& pQua,
263 Quaternion& pQuaOut);
264
274 ALMATH_API Quaternion quaternionInverse(const Quaternion& pQua);
275
276
289 ALMATH_API Quaternion quaternionFromAngleAndAxisRotation(
290 const float pAngle,
291 const float pAxisX,
292 const float pAxisY,
293 const float pAxisZ);
294
295
306 ALMATH_API void angleAndAxisRotationFromQuaternion(
307 const Quaternion& pQuaternion,
308 float& pAngle,
309 float& pAxisX,
310 float& pAxisY,
311 float& pAxisZ);
312
322 ALMATH_API std::vector<float> angleAndAxisRotationFromQuaternion(
323 const Quaternion& pQuaternion);
324
325
326 } // end namespace math
327 } // end namespace al
328 #endif // _LIBALMATH_ALMATH_TYPES_ALQUATERNION_H_
AL::Math::Quaternion::w
float w
Definition: alquaternion.h:26
AL::Math::angleAndAxisRotationFromQuaternion
ALMATH_API void angleAndAxisRotationFromQuaternion(const Quaternion &pQuaternion, float &pAngle, float &pAxisX, float &pAxisY, float &pAxisZ)
Compute angle and axis rotation from a Quaternion.
qi::geometry::isNear
bool isNear(const Transform &lhs, const Transform &rhs, double epsilon)
Definition: qigeometry.h:111
AL::urdf::operator!=
bool operator!=(const Pose &lhs, const Pose &rhs)
Definition: urdf.h:340
AL::Math::Quaternion::y
float y
Definition: alquaternion.h:30
qi::geometry::inverse
Transform inverse(const Transform &tf)
Definition: qigeometry.h:120
AL::Math::quaternionFromAngleAndAxisRotation
ALMATH_API Quaternion quaternionFromAngleAndAxisRotation(const float pAngle, const float pAxisX, const float pAxisY, const float pAxisZ)
Create a Quaternion initialized with explicit angle and axis rotation.
AL::Math::Quaternion::z
float z
Definition: alquaternion.h:32
AL::Math::normalize
ALMATH_API Position2D normalize(const Position2D &pPos)
Normalize a Position2D.
AL::Math::quaternionInverse
ALMATH_API void quaternionInverse(const Quaternion &pQua, Quaternion &pQuaOut)
Return the quaternion inverse of the given Quaternion:
AL::Math::Quaternion::x
float x
Definition: alquaternion.h:28
AL::Math::norm
ALMATH_API float norm(const Position2D &pPos)
Compute the norm of a Position2D.
AL::Math::operator==
bool operator==(const BodyMass< T > &lhs, const BodyMass< T > &rhs)
Definition: bodymass.h:79
AL::Math::Quaternion
Create and play with a Quaternion.
Definition: alquaternion.h:24
AL::Math::operator*
ALMATH_API Position3D operator*(const Rotation &pRot, const Position3D &pPos)
Overloading of operator * between Rotation and Position3D: