libalmath  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alrotation.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_ALROTATION_H_
10 #define _LIBALMATH_ALMATH_TYPES_ALROTATION_H_
11 
12 #include <vector>
13 #include <almath/api.h>
14 
15 namespace AL {
16  namespace Math {
17 
20 
28  struct ALMATH_API Rotation
32  {
36  float r1_c1;
40  float r1_c2;
44  float r1_c3;
48  float r2_c1;
52  float r2_c2;
56  float r2_c3;
60  float r3_c1;
64  float r3_c2;
68  float r3_c3;
69 
72 
85  Rotation();
87 
96 
110 
126  Rotation (const std::vector<float>& pFloats);
128 
133  Rotation& operator*= (const Rotation& pRot2);
134 
139  Rotation operator* (const Rotation& pRot2) const;
140 
145  bool operator==(const Rotation& pRot2) const;
146 
151  bool operator!=(const Rotation& pRot2) const;
152 
163  bool isNear(
164  const Rotation& pRot2,
165  const float& pEpsilon=0.0001f) const;
166 
171  void normalizeRotation(void);
172 
185  bool isRotation(const float& pEpsilon=0.0001f) const;
186 
193  Rotation transpose() const;
194 
198 
205  float determinant() const;
210 
218  static Rotation fromQuaternion(
219  const float pA,
220  const float pB,
221  const float pC,
222  const float pD);
223 
224 
232  static Rotation fromAngleDirection(
233  const float pAngle,
234  const float pX,
235  const float pY,
236  const float pZ);
237 
241 
247  static Rotation fromRotX(const float pRotX);
250 
251  static Rotation fromRotXPi() {
252  Rotation r; // identity
253  r.r2_c2 = -1.f;
254  r.r3_c3 = -1.f;
255  return r;
256  }
257 
261 
267  static Rotation fromRotY(const float pRotY);
270 
271  static Rotation fromRotYPi() {
272  Rotation r; // identity
273  r.r1_c1 = -1.f;
274  r.r3_c3 = -1.f;
275  return r;
276  }
277 
281 
287  static Rotation fromRotZ(const float pRotZ);
290 
294  static Rotation fromRotZPi() {
295  Rotation r; // identity
296  r.r1_c1 = -1.f;
297  r.r2_c2 = -1.f;
298  return r;
299  }
300 
304  static Rotation fromRotZHalfPi() {
305  Rotation r; // identity
306  r.r1_c1 = 0.f;
307  r.r1_c2 = -1.f;
308  r.r2_c1 = 1.f;
309  r.r2_c2 = 0.f;
310  return r;
311  }
312 
322  static Rotation from3DRotation(
323  const float& pWX,
324  const float& pWY,
325  const float& pWZ);
326 
330 
336  void toVector(std::vector<float>& pReturnValue) const;
338  std::vector<float> toVector(void) const;
339 
340  }; // end struct
341 
351  ALMATH_API Rotation transpose(const Rotation& pRot);
352 
353 
357 
364  ALMATH_API float determinant(const Rotation& pRot);
371 
378  ALMATH_API void normalizeRotation(Rotation& pRot);
379 
391  ALMATH_API Rotation rotationFromQuaternion(
392  const float pA,
393  const float pB,
394  const float pC,
395  const float pD);
396 
408  ALMATH_API Rotation rotationFromAngleDirection(
409  const float pAngle,
410  const float pX,
411  const float pY,
412  const float pZ);
413 
422  ALMATH_API void applyRotation(
423  const AL::Math::Rotation& pRot,
424  float& pX,
425  float& pY,
426  float& pZ);
427 
431 
437  ALMATH_API Rotation rotationFromRotX(const float pRotX);
444 
448 
454  ALMATH_API Rotation rotationFromRotY(const float pRotY);
461 
465 
470  ALMATH_API Rotation rotationFromRotZ(const float pRotZ);
477 
490  ALMATH_API Rotation rotationFrom3DRotation(
491  const float& pWX,
492  const float& pWY,
493  const float& pWZ);
494 
495  }
496 }
497 #endif // _LIBALMATH_ALMATH_TYPES_ALROTATION_H_
float r2_c1
row 2 column 1.
Definition: alrotation.h:48
ALMATH_API Rotation rotationFrom3DRotation(const float &pWX, const float &pWY, const float &pWZ)
Create a Rotation initialized with euler angle. Rot = fromRotZ(pWZ)*fromRotY(pWY)*fromRotX(pWX) ...
float r3_c1
row 3 column 1.
Definition: alrotation.h:60
float r3_c2
row 3 column 2.
Definition: alrotation.h:64
static Rotation fromRotXPi()
Definition: alrotation.h:251
static Rotation fromRotZHalfPi()
Create a Rotation initialized with rotation of pi/2 around z axis.
Definition: alrotation.h:304
A 3*3 rotation matrix.
Definition: alrotation.h:31
bool isNear(const Transform &lhs, const Transform &rhs, double epsilon)
Definition: qigeometry.h:111
float r1_c2
row 1 column 2.
Definition: alrotation.h:40
ALMATH_API Rotation rotationFromRotZ(const float pRotZ)
Create a Rotation initialized with explicit rotation around z axis.
bool operator!=(const Pose &lhs, const Pose &rhs)
Definition: urdf.h:340
ALMATH_API Rotation rotationFromRotY(const float pRotY)
Create a Rotation initialized with explicit rotation around y axis.
ALMATH_API float determinant(const Rotation &pRot)
Compute the determinant of the given Rotation:
ALMATH_API void normalizeRotation(Rotation &pRot)
Normalize data, if needed, to have Rotation properties.
float r2_c2
row 2 column 2.
Definition: alrotation.h:52
static Rotation fromRotZPi()
Create a Rotation initialized with rotation of pi around z axis.
Definition: alrotation.h:294
float r2_c3
row 2 column 3.
Definition: alrotation.h:56
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 Rotation transpose(const Rotation &pRot)
Compute the transpose rotation of the one given in argument:
float r3_c3
row 3 column 3.
Definition: alrotation.h:68
ALMATH_API void applyRotation(const AL::Math::Rotation &pRot, float &pX, float &pY, float &pZ)
Apply Rotation to a 3D point.
static Rotation fromRotYPi()
Definition: alrotation.h:271
float r1_c1
row 1 column 1.
Definition: alrotation.h:36
bool operator==(const BodyMass< T > &lhs, const BodyMass< T > &rhs)
Definition: bodymass.h:79
ALMATH_API Rotation rotationFromRotX(const float pRotX)
Create a Rotation initialized with explicit rotation around x axis.
float r1_c3
row 1 column 3.
Definition: alrotation.h:44
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