libalmath  2.1.4.13
 All Classes Namespaces Functions Variables Typedefs Groups Pages
altransform.h
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  }; // end struct
360 
369  const Transform& pT,
370  Transform& pTOut);
371 
382  float norm(const Transform& pT);
383 
390  void normalizeTransform(Transform& pT);
391 
396 
409  const Transform& pT,
410  std::vector<float>& pTOut);
411 
416 
424  std::vector<float> transformToFloatVector(
432  const Transform& pT);
433 
434 
438 
442  float determinant(const Transform& pT);
449 
453 
457  float determinant(const std::vector<float>& pFloats);
464 
468 
473 
479  void transformInverse(
485  const Transform& pT,
486  Transform& pTOut);
487 
491 
496 
510 
511 
515 
522  Transform transformFromRotX(const float pRotX);
530 
534 
541  Transform transformFromRotY(const float pRotY);
549 
553 
560  Transform transformFromRotZ(const float pRotZ);
568 
569 
583  const float& pWX,
584  const float& pWY,
585  const float& pWZ);
586 
590 
607  const float& pX,
608  const float& pY,
609  const float& pZ);
610 
634  const float& pX,
635  const float& pY,
636  const float& pZ,
637  const float& pWX,
638  const float& pWY,
639  const float& pWZ);
640 
641 
649 
650 
654 
659 
665  Transform pinv(const Transform& pT);
670 
671 
685  const Transform& pT1,
686  const Transform& pT2);
687 
701  const Transform& pT1,
702  const Transform& pT2);
703 
704 
717  float transformDistance(
718  const Transform& pT1,
719  const Transform& pT2);
720 
721  } // end namespace Math
722 } // end namespace AL
723 #endif // _LIBALMATH_ALMATH_TYPES_ALTRANSFORM_H_
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) ...
void toVector(std::vector< float > &pReturnVector) const
Return the Transform as a vector of float:
Transform inverse() const
Compute the transform inverse of the actual Transform:
float determinant() const
Compute the determinant of rotation part of the actual Transform:
static Transform fromRotY(const float pRotY)
Create a Transform initialized with explicit rotation around y axis.
Transform & operator*=(const Transform &pT2)
Overloading of operator *= for Transform.
Transform transformFromPosition(const float &pX, const float &pY, const float &pZ, const float &pWX, const float &pWY, const float &pWZ)
Create a Transform initialize with explicit value for translation part and euler angle: ...
float determinant(const std::vector< float > &pFloats)
Compute the determinant of rotation part of the given vector of floats:
static Transform fromPosition(const float pX, const float pY, const float pZ)
Create a Transform initialize with explicit value for translation part.
Transform diff(const Transform &pT2) const
Compute the Transform between the actual Transform and the one given in argument: ...
A homogenous transformation matrix.
Definition: altransform.h:22
static Transform fromRotZ(const float pRotZ)
Create a Transform initialized with explicit rotation around z axis.
Transform transformInverse(const Transform &pT)
Return the transform inverse of the given Transform:
bool isTransform(const float &pEpsilon=0.0001f) const
Check if the rotation part is correct. The condition checks are: and determinant(R) = 1...
Transform transformFromRotX(const float pRotX)
Create a Transform initialize with explicit rotation around x axis:
Transform transformFromRotY(const float pRotY)
Create a Transform initialize with explicit rotation around y axis:
static Transform from3DRotation(const float &pWX, const float &pWY, const float &pWZ)
Create a Transform initialize with euler angle.
static Transform fromRotX(const float pRotX)
Create a Transform initialized with explicit rotation around x axis.
void normalizeTransform(void)
Normalize data, if needed, to have transform properties.
void normalizeTransform(Transform &pT)
Normalize data, if needed, to have transform properties.
bool isNear(const Transform &pT2, const float &pEpsilon=0.0001f) const
Check if the actual Transform is near the one given in argument.
void transformPreMultiply(const Transform &pT, Transform &pTOut)
pTOut = pT*pTOut
float distance(const Transform &pT2) const
Compute the distance between the actual Transform and the one given in argument:
Transform pinv(const Transform &pT)
Alternative name for inverse: return the transform inverse of the given Transform: ...
Transform()
Create a Transform initialized to identity.
std::vector< float > transformToFloatVector(const Transform &pT)
DEPRECATED: Use toVector function. Return the Transform in a vector of float:
float transformDistance(const Transform &pT1, const Transform &pT2)
Compute the distance between the actual Transform and the one give in argument:
float norm(const Transform &pT)
Compute the norm translation part of the actual Transform:
float distanceSquared(const Transform &pT2) const
Compute the squared distance between the actual Transform and the one given in argument (translation ...
bool operator!=(const Transform &pT2) const
Overloading of operator != for Transform.
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 transformDiff(const Transform &pT1, const Transform &pT2)
Compute the Transform between the actual Transform and the one give in argument result: ...
bool operator==(const Transform &pT2) const
Overloading of operator == for Transform.
Transform transformFromRotZ(const float pRotZ)
Create a Transform initialize with explicit rotation around z axis:
float norm() const
Compute the norm translation part of the actual Transform:
void transformInvertInPlace(Transform &pT)
Inverse the given Transform in place:
Transform operator*(const Transform &pT2) const
Overloading of operator * for Transform.