libalmath  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
altransform.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_ALTRANSFORM_H_
10 #define _LIBALMATH_ALMATH_TYPES_ALTRANSFORM_H_
11 
12 #include <vector>
13 #include <almath/api.h>
14 
15 namespace AL {
16  namespace Math {
23  struct ALMATH_API Transform {
24 
26  float r1_c1, r1_c2, r1_c3, r1_c4;
27  float r2_c1, r2_c2, r2_c3, r2_c4;
28  float r3_c1, r3_c2, r3_c3, r3_c4;
31 
48  Transform();
50 
57 
72  explicit Transform(const std::vector<float>& pFloats);
73 
77 
92  Transform(
97  const float& pPosX,
98  const float& pPosY,
99  const float& pPosZ);
100 
105  Transform& operator*= (const Transform& pT2);
106 
111  Transform operator* (const Transform& pT2) const;
112 
117  bool operator==(const Transform& pT2) const;
118 
123  bool operator!=(const Transform& pT2) const;
124 
135  bool isNear(
136  const Transform& pT2,
137  const float& pEpsilon=0.0001f) const;
138 
151  bool isTransform(
152  const float& pEpsilon=0.0001f) const;
153 
158  void normalizeTransform(void);
159 
168  float norm() const;
169 
173 
178  float determinant() const;
183 
187 
191 
197  Transform inverse() const;
203 
207 
213  static Transform fromRotX(const float pRotX);
216 
220 
228  static Transform fromRotY(const float pRotY);
231 
235 
243  static Transform fromRotZ(const float pRotZ);
246 
247 
257  static Transform from3DRotation(
258  const float& pWX,
259  const float& pWY,
260  const float& pWZ);
261 
262 
266 
274  static Transform fromPosition(
279  const float pX,
280  const float pY,
281  const float pZ);
282 
303  static Transform fromPosition(
304  const float& pX,
305  const float& pY,
306  const float& pZ,
307  const float& pWX,
308  const float& pWY,
309  const float& pWZ);
310 
319  Transform diff(const Transform& pT2) const;
320 
321 
332  float distanceSquared(const Transform& pT2) const;
333 
334 
345  float distance(const Transform& pT2) const;
346 
350 
357  void toVector(std::vector<float>& pReturnVector) const;
359  std::vector<float> toVector(void) const;
360 
364 
371  void writeToVector(std::vector<float>::iterator& pIt) const;
374  }; // end struct
375 
383  ALMATH_API void transformPreMultiply(
384  const Transform& pT,
385  Transform& pTOut);
386 
397  ALMATH_API float norm(const Transform& pT);
398 
405  ALMATH_API void normalizeTransform(Transform& pT);
406 
411 
418  ALMATH_API void transformToFloatVector(
424  const Transform& pT,
425  std::vector<float>& pTOut);
426 
431 
439  ALMATH_API std::vector<float> transformToFloatVector(
447  const Transform& pT);
448 
449 
453 
457  ALMATH_API float determinant(const Transform& pT);
464 
468 
472  ALMATH_API float determinant(const std::vector<float>& pFloats);
479 
483 
488 
494  ALMATH_API void transformInverse(
500  const Transform& pT,
501  Transform& pTOut);
502 
506 
511 
517  ALMATH_API Transform transformInverse(const Transform& pT);
525 
526 
530 
537  ALMATH_API Transform transformFromRotX(const float pRotX);
545 
549 
556  ALMATH_API Transform transformFromRotY(const float pRotY);
564 
568 
575  ALMATH_API Transform transformFromRotZ(const float pRotZ);
583 
584 
598  const float& pWX,
599  const float& pWY,
600  const float& pWZ);
601 
605 
612  ALMATH_API Transform transformFromPosition(
622  const float& pX,
623  const float& pY,
624  const float& pZ);
625 
648  ALMATH_API Transform transformFromPosition(
649  const float& pX,
650  const float& pY,
651  const float& pZ,
652  const float& pWX,
653  const float& pWY,
654  const float& pWZ);
655 
656 
663  ALMATH_API void transformInvertInPlace(Transform& pT);
664 
665 
669 
674 
680  ALMATH_API Transform pinv(const Transform& pT);
685 
686 
699  ALMATH_API Transform transformDiff(
700  const Transform& pT1,
701  const Transform& pT2);
702 
715  ALMATH_API float transformDistanceSquared(
716  const Transform& pT1,
717  const Transform& pT2);
718 
719 
732  ALMATH_API float transformDistance(
733  const Transform& pT1,
734  const Transform& pT2);
735 
736  } // end namespace Math
737 } // end namespace AL
738 #endif // _LIBALMATH_ALMATH_TYPES_ALTRANSFORM_H_
ALMATH_API Pose2D pinv(const Pose2D &pPos)
Alternative name for inverse: return the pose2d inverse of the given Pose2D.
ALMATH_API float distance(const Pose2D &pPos1, const Pose2D &pPos2)
Compute the distance between two Pose2D.
ALMATH_API void normalizeTransform(Transform &pT)
Normalize data, if needed, to have transform properties.
ALMATH_API float transformDistance(const Transform &pT1, const Transform &pT2)
Compute the distance between the actual Transform and the one give in argument:
ALMATH_API void transformInverse(const Transform &pT, Transform &pTOut)
Return the transform inverse of the given Transform:
bool isNear(const Transform &lhs, const Transform &rhs, double epsilon)
Definition: qigeometry.h:111
ALMATH_API float distanceSquared(const Pose2D &pPos1, const Pose2D &pPos2)
Compute the squared distance between two Pose2D.
bool operator!=(const Pose &lhs, const Pose &rhs)
Definition: urdf.h:340
ALMATH_API void transformToFloatVector(const Transform &pT, std::vector< float > &pTOut)
DEPRECATED: Use toVector function. Copy the Transform in a vector of float:
Transform inverse(const Transform &tf)
Definition: qigeometry.h:120
ALMATH_API float determinant(const Rotation &pRot)
Compute the determinant of the given Rotation:
ALMATH_API void transformPreMultiply(const Transform &pT, Transform &pTOut)
pTOut = pT*pTOut
ALMATH_API Transform transformFromRotY(const float pRotY)
Create a Transform initialize with explicit rotation around y axis:
ALMATH_API void transformInvertInPlace(Transform &pT)
Inverse the given Transform in place:
ALMATH_API Transform transformFromRotX(const float pRotX)
Create a Transform initialize with explicit rotation around x axis:
ALMATH_API Transform transformFrom3DRotation(const float &pWX, const float &pWY, const float &pWZ)
Create a Transform initialize with euler angle: H = fromRotZ(pWZ)*fromRotY(pWY)*fromRotX(pWX) ...
ALMATH_API Transform transformFromRotZ(const float pRotZ)
Create a Transform initialize with explicit rotation around z axis:
A homogenous transformation matrix.
Definition: altransform.h:23
ALMATH_API Transform transformDiff(const Transform &pT1, const Transform &pT2)
Compute the Transform between the actual Transform and the one give in argument result: ...
ALMATH_API Transform transformFromPosition(const float &pX, const float &pY, const float &pZ)
Create a Transform initialize with explicit value for translation part:
ALMATH_API float norm(const Position2D &pPos)
Compute the norm of a Position2D.
bool operator==(const BodyMass< T > &lhs, const BodyMass< T > &rhs)
Definition: bodymass.h:79
ALMATH_API Position3D operator*(const Rotation &pRot, const Position3D &pPos)
Overloading of operator * between Rotation and Position3D:
ALMATH_API float transformDistanceSquared(const Transform &pT1, const Transform &pT2)
Compute the squared distance between the actual Transform and the one give in argument (translation p...