libalmath  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
almath.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_TOOLS_ALMATH_H_
10 #define _LIBALMATH_ALMATH_TOOLS_ALMATH_H_
11 
20 #include <almath/types/alpose2d.h>
21 
22 namespace AL {
23  namespace Math {
24 
31  ALMATH_API void modulo2PIInPlace(float& pAngle);
32 
42  ALMATH_API float modulo2PI(float pAngle);
43 
55  ALMATH_API float meanAngle(const std::vector<float>& pAngles);
56 
72  ALMATH_API float weightedMeanAngle(const std::vector<float>& pAngles,
73  const std::vector<float>& pWeights);
74 
88  ALMATH_API bool clipData(
89  const float& pMin,
90  const float& pMax,
91  float& pData);
92 
93  ALMATH_API bool clipData(
94  const float& pMin,
95  const float& pMax,
96  std::vector<float>& pData);
97 
98  ALMATH_API bool clipData(
99  const float& pMin,
100  const float& pMax,
101  std::vector<std::vector<float> >& pData);
102 
104 
123  ALMATH_API void changeReferencePose2D(
129  const float& pTheta,
130  const Pose2D& pPosIn,
131  Pose2D& pPosOut);
132 
139  ALMATH_API void changeReferencePose2DInPlace(
140  const float& pTheta,
141  Pose2D& pPosOut);
142 
146 
155  ALMATH_API Position6D position6DFromVelocity6D(const Velocity6D& pVel);
163 
171  ALMATH_API void position2DFromPose2DInPlace(
172  const Pose2D& pPose2D,
173  Position2D& pPosition2D);
174 
178 
183  ALMATH_API Position2D position2DFromPose2D(const Pose2D& pPose2D);
191 
195 
201  ALMATH_API Position3D position3DFromPosition6D(const Position6D& pPosition6D);
209 
213 
229  ALMATH_API Position3D operator*(
238  const Rotation& pRot,
239  const Position3D& pPos);
240 
250  ALMATH_API Position3D operator*(
251  const Quaternion& pQuat,
252  const Position3D& pPos);
253 
254 
258 
267  ALMATH_API Velocity6D operator*(
276  const float pVal,
277  const Position6D& pPos);
278 
282 
288  ALMATH_API Velocity3D operator*(
297  const float pVal,
298  const Position3D& pPos);
299 
303 
319  ALMATH_API Velocity3D operator*(
328  const Rotation& pRot,
329  const Velocity3D& pVel);
330 
340  ALMATH_API Rotation rotationFromAngleDirection(
341  const float& pTheta,
342  const Position3D& pPos);
343 
344 
351  ALMATH_API void position6DFromPose2DInPlace(
352  const Pose2D& pPose2D,
353  Position6D& pPosition6D);
354 
361  ALMATH_API Position6D position6DFromPose2D(const Pose2D& pPose2D);
362 
369  ALMATH_API void position6DFromPosition3DInPlace(
370  const Position3D& pPosition3D,
371  Position6D& pPosition6D);
372 
379  ALMATH_API Position6D position6DFromPosition3D(const Position3D& pPosition3D);
380 
387  ALMATH_API void pose2DFromPosition6DInPlace(
388  const Position6D& pPosition6D,
389  Pose2D& pPose2D);
390 
397  ALMATH_API Pose2D pose2DFromPosition6D(const Position6D& pPosition6D);
398 
409  ALMATH_API void pose2DFromPosition2DInPlace(
410  const Position2D& pPosition2D,
411  const float pAngle,
412  Pose2D& pPose2D);
413 
421  ALMATH_API Pose2D pose2DFromPosition2D(const Position2D& pPosition2D,
422  const float pAngle=0.0f);
423 
427 
432  ALMATH_API Position2D operator*(
441  const Pose2D& pVal,
442  const Position2D& pPos);
443 
451  ALMATH_API void quaternionFromRotation3D(
452  const Rotation3D& pRot3D,
453  Quaternion& pQuaternion);
454 
455  ALMATH_API Quaternion quaternionFromRotation3D(
456  const Rotation3D& pRot3D);
457 
464  ALMATH_API void rotationFromQuaternion(
465  const Quaternion& pQua,
466  Rotation& pRot);
467 
468  ALMATH_API Rotation rotationFromQuaternion(
469  const Quaternion& pQua);
470 
478  ALMATH_API void rotation3DFromQuaternion(
479  const Quaternion& pQuaterion,
480  Rotation3D& pRot3D);
481 
482  ALMATH_API Rotation3D rotation3DFromQuaternion(
483  const Quaternion& pQuaternion);
484 
492  ALMATH_API void quaternionPosition3DFromPosition6D(
493  const Position6D& pPos6D,
494  Quaternion& pQua,
495  Position3D& pPos3D);
496 
497 
501 
509  ALMATH_API void pointMassRotationalInertia(
533  float pMass,
534  const Position3D& pPos,
535  std::vector<float>& pInertia);
536  } // namespace Math
537 } // namespace AL
538 #endif // _LIBALMATH_ALMATH_TOOLS_ALMATH_H_
ALMATH_API float weightedMeanAngle(const std::vector< float > &pAngles, const std::vector< float > &pWeights)
Returns the weighted mean of given angles (between ]-PI, PI]). It is defined by the direction of the ...
ALMATH_API void pose2DFromPosition6DInPlace(const Position6D &pPosition6D, Pose2D &pPose2D)
Compute a Pose2D from a Position6D.
ALMATH_API void rotation3DFromQuaternion(const Quaternion &pQuaterion, Rotation3D &pRot3D)
Create a Rotation3D from a Quaternion when composed in the following order: Rz(wz) * Ry(wy) * Rx(wx) ...
ALMATH_API float meanAngle(const std::vector< float > &pAngles)
Returns the mean of given angles (between ]-PI, PI]). It is defined by the direction of the mean of a...
ALMATH_API void quaternionPosition3DFromPosition6D(const Position6D &pPos6D, Quaternion &pQua, Position3D &pPos3D)
Convert a Position6D to Quaternion and Position3D
ALMATH_API Pose2D pose2DFromPosition6D(const Position6D &pPosition6D)
Create a Pose2D from a Position6D.
ALMATH_API Position6D position6DFromPose2D(const Pose2D &pPose2D)
Create a Position6D from a Pose2D.
ALMATH_API Position6D position6DFromVelocity6D(const Velocity6D &pVel)
Create a Position6D from a Velocity6D
ALMATH_API void modulo2PIInPlace(float &pAngle)
Set an angle between ]-PI, PI].
ALMATH_API Position3D position3DFromPosition6D(const Position6D &pPosition6D)
Create a Position3D from a Position6D
ALMATH_API void position6DFromPosition3DInPlace(const Position3D &pPosition3D, Position6D &pPosition6D)
Compute a Position6D from a Position3D.
ALMATH_API void position2DFromPose2DInPlace(const Pose2D &pPose2D, Position2D &pPosition2D)
Compute a Position2D from a Pose2D. The theta member of the Pose2D is not taken into account...
ALMATH_API void changeReferencePose2DInPlace(const float &pTheta, Pose2D &pPosOut)
Change orientation of a Pose2D in place.
ALMATH_API void quaternionFromRotation3D(const Rotation3D &pRot3D, Quaternion &pQuaternion)
Create a Quaternion from a Rotation3D when composed in the following order: Rz(wz) * Ry(wy) * Rx(wx) ...
ALMATH_API void changeReferencePose2D(const float &pTheta, const Pose2D &pPosIn, Pose2D &pPosOut)
ALMATH_API void pointMassRotationalInertia(float pMass, const Position3D &pPos, std::vector< float > &pInertia)
Return the rotational inertia, expressed at the origin, of a point mass located at pPos...
ALMATH_API Rotation rotationFromAngleDirection(const float &pTheta, const Position3D &pPos)
Creates a 3*3 Rotation Matrix from a an angle and a normalized Position3D.
ALMATH_API float modulo2PI(float pAngle)
Return an angle between ]-PI, PI].
ALMATH_API void pose2DFromPosition2DInPlace(const Position2D &pPosition2D, const float pAngle, Pose2D &pPose2D)
Compute a Pose2D from a Position2D. pPose2D.x = pPosition2D.x pPose2D.y = pPosition2D.y pPose2D.theta = pAngle
ALMATH_API Position2D position2DFromPose2D(const Pose2D &pPose2D)
Create a Position2D from a Pose2D
ALMATH_API Position6D position6DFromPosition3D(const Position3D &pPosition3D)
Create a Position6D from a Position3D.
ALMATH_API bool clipData(const float &pMin, const float &pMax, float &pData)
Clip an input data inside min and max limit.
ALMATH_API Pose2D pose2DFromPosition2D(const Position2D &pPosition2D, const float pAngle=0.0f)
Create a Pose2D from a Position2D.
ALMATH_API void position6DFromPose2DInPlace(const Pose2D &pPose2D, Position6D &pPosition6D)
Compute a Position6D from a Pose2D.
ALMATH_API Position3D operator*(const Rotation &pRot, const Position3D &pPos)
Overloading of operator * between Rotation and Position3D:
ALMATH_API void rotationFromQuaternion(const Quaternion &pQua, Rotation &pRot)
Create a Rotation Matrix from a Quaternion