libalmath  2.4.3.28-r2
 All Classes Namespaces Files Functions Variables Typedefs 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 
14 namespace AL {
15  namespace Math {
16 
19 
27  struct Rotation
31  {
35  float r1_c1;
39  float r1_c2;
43  float r1_c3;
47  float r2_c1;
51  float r2_c2;
55  float r2_c3;
59  float r3_c1;
63  float r3_c2;
67  float r3_c3;
68 
71 
84  Rotation();
86 
95 
109 
125  Rotation (const std::vector<float>& pFloats);
127 
132  Rotation& operator*= (const Rotation& pRot2);
133 
138  Rotation operator* (const Rotation& pRot2) const;
139 
144  bool operator==(const Rotation& pRot2) const;
145 
150  bool operator!=(const Rotation& pRot2) const;
151 
162  bool isNear(
163  const Rotation& pRot2,
164  const float& pEpsilon=0.0001f) const;
165 
170  void normalizeRotation(void);
171 
184  bool isRotation(const float& pEpsilon=0.0001f) const;
185 
192  Rotation transpose() const;
193 
197 
204  float determinant() const;
209 
217  static Rotation fromQuaternion(
218  const float pA,
219  const float pB,
220  const float pC,
221  const float pD);
222 
223 
232  const float pAngle,
233  const float pX,
234  const float pY,
235  const float pZ);
236 
240 
246  static Rotation fromRotX(const float pRotX);
249 
253 
259  static Rotation fromRotY(const float pRotY);
262 
266 
272  static Rotation fromRotZ(const float pRotZ);
275 
285  static Rotation from3DRotation(
286  const float& pWX,
287  const float& pWY,
288  const float& pWZ);
289 
293 
299  void toVector(std::vector<float>& pReturnValue) const;
301  std::vector<float> toVector(void) const;
302 
303  }; // end struct
304 
314  Rotation transpose(const Rotation& pRot);
315 
316 
320 
327  float determinant(const Rotation& pRot);
334 
341  void normalizeRotation(Rotation& pRot);
342 
355  const float pA,
356  const float pB,
357  const float pC,
358  const float pD);
359 
372  const float pAngle,
373  const float pX,
374  const float pY,
375  const float pZ);
376 
385  void applyRotation(
386  const AL::Math::Rotation& pRot,
387  float& pX,
388  float& pY,
389  float& pZ);
390 
394 
400  Rotation rotationFromRotX(const float pRotX);
407 
411 
417  Rotation rotationFromRotY(const float pRotY);
424 
428 
433  Rotation rotationFromRotZ(const float pRotZ);
440 
454  const float& pWX,
455  const float& pWY,
456  const float& pWZ);
457 
458  }
459 }
460 #endif // _LIBALMATH_ALMATH_TYPES_ALROTATION_H_
Rotation & operator*=(const Rotation &pRot2)
Overloading of operator *= for Rotation.
void normalizeRotation(void)
Normalize data, if needed, to have Rotation properties.
float r2_c1
row 2 column 1.
Definition: alrotation.h:47
Rotation rotationFromRotX(const float pRotX)
Create a Rotation initialized with explicit rotation around x axis.
bool operator!=(const Rotation &pRot2) const
Overloading of operator != for Rotation.
Rotation operator*(const Rotation &pRot2) const
Overloading of operator * for Rotation.
bool operator==(const Rotation &pRot2) const
Overloading of operator == for Rotation.
static Rotation fromRotX(const float pRotX)
Create a Rotation initialized with explicit rotation around x axis.
float r3_c1
row 3 column 1.
Definition: alrotation.h:59
float r3_c2
row 3 column 2.
Definition: alrotation.h:63
Rotation()
Create a Rotation initialized to identity.
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) ...
A 3*3 rotation matrix.
Definition: alrotation.h:30
Rotation transpose(const Rotation &pRot)
Compute the transpose rotation of the one given in argument:
float r1_c2
row 1 column 2.
Definition: alrotation.h:39
std::vector< float > toVector(void) const
Rotation rotationFromRotY(const float pRotY)
Create a Rotation initialized with explicit rotation around y axis.
bool isRotation(const float &pEpsilon=0.0001f) const
Check if the rotation is correct. The condition checks are: and determinant(R) = 1...
static Rotation fromQuaternion(const float pA, const float pB, const float pC, const float pD)
Creates a 3*3 Rotation Matrix from a normalized quaternion ( |a + bi + cj + dk| = 1)...
Rotation transpose() const
Compute the rotation transpose (inverse) of the actual Rotation:
Rotation rotationFromAngleDirection(const float &pTheta, const Position3D &pPos)
Creates a 3*3 Rotation Matrix from a an angle and a normalized Position3D.
float r2_c2
row 2 column 2.
Definition: alrotation.h:51
Rotation rotationFromRotZ(const float pRotZ)
Create a Rotation initialized with explicit rotation around z axis.
static Rotation from3DRotation(const float &pWX, const float &pWY, const float &pWZ)
Create a Rotation initialized with euler angle.
static Rotation fromAngleDirection(const float pAngle, const float pX, const float pY, const float pZ)
Creates a 3*3 Rotation Matrix from a an angle and a normalized direction( |pX, pY, pZ| = 1).
float r2_c3
row 2 column 3.
Definition: alrotation.h:55
float r3_c3
row 3 column 3.
Definition: alrotation.h:67
static Rotation fromRotZ(const float pRotZ)
Create a Rotation initialized with explicit rotation around z axis.
float determinant(const Rotation &pRot)
Compute the determinant of the given Rotation:
float r1_c1
row 1 column 1.
Definition: alrotation.h:35
static Rotation fromRotY(const float pRotY)
Create a Rotation initialized with explicit rotation around y axis.
void applyRotation(const AL::Math::Rotation &pRot, float &pX, float &pY, float &pZ)
Apply Rotation to a 3D point.
bool isNear(const Rotation &pRot2, const float &pEpsilon=0.0001f) const
Check if the actual Rotation is near the one give in argument.
void rotationFromQuaternion(const Quaternion &pQua, Rotation &pRot)
Create a Rotation Matrix from a Quaternion
float determinant() const
Compute the determinant of the Rotation:
float r1_c3
row 1 column 3.
Definition: alrotation.h:43
void normalizeRotation(Rotation &pRot)
Normalize data, if needed, to have Rotation properties.