libalmath  2.5.7.1
 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 
14 namespace AL {
15  namespace Math {
22  struct Transform {
23 
25  float r1_c1, r1_c2, r1_c3, r1_c4;
26  float r2_c1, r2_c2, r2_c3, r2_c4;
27  float r3_c1, r3_c2, r3_c3, r3_c4;
30 
47  Transform();
49 
56 
71  explicit Transform(const std::vector<float>& pFloats);
72 
76 
91  Transform(
96  const float& pPosX,
97  const float& pPosY,
98  const float& pPosZ);
99 
104  Transform& operator*= (const Transform& pT2);
105 
110  Transform operator* (const Transform& pT2) const;
111 
116  bool operator==(const Transform& pT2) const;
117 
122  bool operator!=(const Transform& pT2) const;
123 
134  bool isNear(
135  const Transform& pT2,
136  const float& pEpsilon=0.0001f) const;
137 
150  bool isTransform(
151  const float& pEpsilon=0.0001f) const;
152 
157  void normalizeTransform(void);
158 
167  float norm() const;
168 
172 
177  float determinant() const;
182 
186 
190 
196  Transform inverse() const;
202 
206 
212  static Transform fromRotX(const float pRotX);
215 
219 
227  static Transform fromRotY(const float pRotY);
230 
234 
242  static Transform fromRotZ(const float pRotZ);
245 
246 
256  static Transform from3DRotation(
257  const float& pWX,
258  const float& pWY,
259  const float& pWZ);
260 
261 
265 
273  static Transform fromPosition(
278  const float pX,
279  const float pY,
280  const float pZ);
281 
302  static Transform fromPosition(
303  const float& pX,
304  const float& pY,
305  const float& pZ,
306  const float& pWX,
307  const float& pWY,
308  const float& pWZ);
309 
318  Transform diff(const Transform& pT2) const;
319 
320 
331  float distanceSquared(const Transform& pT2) const;
332 
333 
344  float distance(const Transform& pT2) const;
345 
349 
356  void toVector(std::vector<float>& pReturnVector) const;
358  std::vector<float> toVector(void) const;
359 
363 
370  void writeToVector(std::vector<float>::iterator& pIt) const;
373  }; // end struct
374 
383  const Transform& pT,
384  Transform& pTOut);
385 
396  float norm(const Transform& pT);
397 
404  void normalizeTransform(Transform& pT);
405 
410 
423  const Transform& pT,
424  std::vector<float>& pTOut);
425 
430 
438  std::vector<float> transformToFloatVector(
446  const Transform& pT);
447 
448 
452 
456  float determinant(const Transform& pT);
463 
467 
471  float determinant(const std::vector<float>& pFloats);
478 
482 
487 
493  void transformInverse(
499  const Transform& pT,
500  Transform& pTOut);
501 
505 
510 
524 
525 
529 
536  Transform transformFromRotX(const float pRotX);
544 
548 
555  Transform transformFromRotY(const float pRotY);
563 
567 
574  Transform transformFromRotZ(const float pRotZ);
582 
583 
597  const float& pWX,
598  const float& pWY,
599  const float& pWZ);
600 
604 
621  const float& pX,
622  const float& pY,
623  const float& pZ);
624 
648  const float& pX,
649  const float& pY,
650  const float& pZ,
651  const float& pWX,
652  const float& pWY,
653  const float& pWZ);
654 
655 
663 
664 
668 
673 
679  Transform pinv(const Transform& pT);
684 
685 
699  const Transform& pT1,
700  const Transform& pT2);
701 
715  const Transform& pT1,
716  const Transform& pT2);
717 
718 
731  float transformDistance(
732  const Transform& pT1,
733  const Transform& pT2);
734 
735  } // end namespace Math
736 } // end namespace AL
737 #endif // _LIBALMATH_ALMATH_TYPES_ALTRANSFORM_H_
Transform transformFromRotZ(const float pRotZ)
Create a Transform initialize with explicit rotation around z axis:
static Transform from3DRotation(const float &pWX, const float &pWY, const float &pWZ)
Create a Transform initialize with euler angle.
float distance(const Transform &pT2) const
Compute the distance between the actual Transform and the one given in argument:
void transformPreMultiply(const Transform &pT, Transform &pTOut)
pTOut = pT*pTOut
void normalizeTransform(void)
Normalize data, if needed, to have transform properties.
float distanceSquared(const Transform &pT2) const
Compute the squared distance between the actual Transform and the one given in argument (translation ...
float norm(const Position2D &pPos)
Compute the norm of a Position2D.
float norm() const
Compute the norm translation part of the actual Transform:
Transform()
Create a Transform initialized to identity.
float determinant() const
Compute the determinant of rotation part of the actual Transform:
void transformToFloatVector(const Transform &pT, std::vector< float > &pTOut)
DEPRECATED: Use toVector function. Copy the Transform in a vector of float:
static Transform fromRotY(const float pRotY)
Create a Transform initialized with explicit rotation around y axis.
std::vector< float > toVector(void) const
bool isTransform(const float &pEpsilon=0.0001f) const
Check if the rotation part is correct. The condition checks are: and determinant(R) = 1...
bool isNear(const Transform &pT2, const float &pEpsilon=0.0001f) const
Check if the actual Transform is near the one given in argument.
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) ...
Transform & operator*=(const Transform &pT2)
Overloading of operator *= for Transform.
Transform transformFromRotX(const float pRotX)
Create a Transform initialize with explicit rotation around x axis:
void normalizeTransform(Transform &pT)
Normalize data, if needed, to have transform properties.
static Transform fromRotZ(const float pRotZ)
Create a Transform initialized with explicit rotation around z axis.
Transform diff(const Transform &pT2) const
Compute the Transform between the actual Transform and the one given in argument: ...
static Transform fromPosition(const float pX, const float pY, const float pZ)
Create a Transform initialize with explicit value for translation part.
bool operator!=(const Transform &pT2) const
Overloading of operator != for Transform.
Transform transformFromPosition(const float &pX, const float &pY, const float &pZ)
Create a Transform initialize with explicit value for translation part:
void writeToVector(std::vector< float >::iterator &pIt) const
Write the Transform in the vector and update the iterator:
A homogenous transformation matrix.
Definition: altransform.h:22
Transform inverse() const
Compute the transform inverse of the actual Transform:
void transformInvertInPlace(Transform &pT)
Inverse the given Transform in place:
float determinant(const Rotation &pRot)
Compute the determinant of the given Rotation:
float transformDistanceSquared(const Transform &pT1, const Transform &pT2)
Compute the squared distance between the actual Transform and the one give in argument (translation p...
Transform operator*(const Transform &pT2) const
Overloading of operator * for Transform.
Transform transformFromRotY(const float pRotY)
Create a Transform initialize with explicit rotation around y axis:
Transform transformDiff(const Transform &pT1, const Transform &pT2)
Compute the Transform between the actual Transform and the one give in argument result: ...
void transformInverse(const Transform &pT, Transform &pTOut)
Return the transform inverse of the given Transform:
static Transform fromRotX(const float pRotX)
Create a Transform initialized with explicit rotation around x axis.
float transformDistance(const Transform &pT1, const Transform &pT2)
Compute the distance between the actual Transform and the one give in argument:
Pose2D pinv(const Pose2D &pPos)
Alternative name for inverse: return the pose2d inverse of the given Pose2D.
bool operator==(const Transform &pT2) const
Overloading of operator == for Transform.