INET Framework for OMNeT++/OMNEST
inet::Rotation Class Reference

#include <Rotation.h>

Public Member Functions

 Rotation ()
 
 Rotation (const EulerAngles &eulerAngle)
 
Coord rotateVectorClockwise (const Coord &vector) const
 
Coord rotateVectorCounterClockwise (const Coord &vector) const
 

Protected Member Functions

void computeRotationMatrices (const double &q0, const double &q1, const double &q2, const double &q3)
 
Coord matrixMultiplication (const double matrix[3][3], const Coord &vector) const
 
Coord matrixTransposeMultiplication (const double matrix[3][3], const Coord &vector) const
 

Protected Attributes

double rotationMatrix [3][3]
 

Constructor & Destructor Documentation

inet::Rotation::Rotation ( )
56 {
57  // identity matrix
58  rotationMatrix[0][0] = 1;
59  rotationMatrix[0][1] = rotationMatrix[0][2] = 0;
60  rotationMatrix[1][1] = 1;
61  rotationMatrix[1][0] = rotationMatrix[1][2] = 0;
62  rotationMatrix[2][2] = 1;
63  rotationMatrix[2][1] = rotationMatrix[2][0] = 0;
64 }
double rotationMatrix[3][3]
Definition: Rotation.h:32
inet::Rotation::Rotation ( const EulerAngles eulerAngle)
23 {
24  // Note that, we don't need to use our Quaternion class since we don't use its operators
25  double q0 = cos(eulerAngle.alpha/2) * cos(eulerAngle.beta/2) * cos(eulerAngle.gamma/2) +
26  sin(eulerAngle.alpha/2) * sin(eulerAngle.beta/2) * sin(eulerAngle.gamma/2);
27  double q1 = sin(eulerAngle.alpha/2) * cos(eulerAngle.beta/2) * cos(eulerAngle.gamma/2) -
28  cos(eulerAngle.alpha/2) * sin(eulerAngle.beta/2) * sin(eulerAngle.gamma/2);
29  double q2 = cos(eulerAngle.alpha/2) * sin(eulerAngle.beta/2) * cos(eulerAngle.gamma/2) +
30  sin(eulerAngle.alpha/2) * cos(eulerAngle.beta/2) * sin(eulerAngle.gamma/2);
31  double q3 = cos(eulerAngle.alpha/2) * cos(eulerAngle.beta/2) * sin(eulerAngle.gamma/2) -
32  sin(eulerAngle.alpha/2) * sin(eulerAngle.beta/2) * cos(eulerAngle.gamma/2);
33  computeRotationMatrices(q0, q1, q2, q3);
34 }
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1201
void computeRotationMatrices(const double &q0, const double &q1, const double &q2, const double &q3)
Definition: Rotation.cc:36
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1195

Member Function Documentation

void inet::Rotation::computeRotationMatrices ( const double &  q0,
const double &  q1,
const double &  q2,
const double &  q3 
)
protected

Referenced by Rotation().

37 {
38  // Ref: http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
39  rotationMatrix[0][0] = 1 - 2*(q2*q2 + q3*q3);
40  rotationMatrix[0][1] = 2*(q1*q2 - q0*q3);
41  rotationMatrix[0][2] = 2*(q0*q2 + q1*q3);
42  rotationMatrix[1][0] = 2*(q1*q2 + q0*q3);
43  rotationMatrix[1][1] = 1 - 2*(q1*q1 + q3*q3);
44  rotationMatrix[1][2] = 2*(q2*q3 - q0*q1);
45  rotationMatrix[2][0] = 2*(q1*q3 - q0*q2);
46  rotationMatrix[2][1] = 2*(q0*q1 + q2*q3);
47  rotationMatrix[2][2] = 1 - 2*(q1*q1 + q2*q2);
48 }
double rotationMatrix[3][3]
Definition: Rotation.h:32
Coord inet::Rotation::matrixMultiplication ( const double  matrix[3][3],
const Coord vector 
) const
protected

Referenced by rotateVectorClockwise().

72 {
73  return Coord(
74  vector.x * matrix[0][0] + vector.y * matrix[0][1] + vector.z * matrix[0][2],
75  vector.x * matrix[1][0] + vector.y * matrix[1][1] + vector.z * matrix[1][2],
76  vector.x * matrix[2][0] + vector.y * matrix[2][1] + vector.z * matrix[2][2]);
77 }
Coord inet::Rotation::matrixTransposeMultiplication ( const double  matrix[3][3],
const Coord vector 
) const
protected

Referenced by rotateVectorCounterClockwise().

80 {
81  return Coord(
82  vector.x * matrix[0][0] + vector.y * matrix[1][0] + vector.z * matrix[2][0],
83  vector.x * matrix[0][1] + vector.y * matrix[1][1] + vector.z * matrix[2][1],
84  vector.x * matrix[0][2] + vector.y * matrix[1][2] + vector.z * matrix[2][2]);
85 }
Coord inet::Rotation::rotateVectorClockwise ( const Coord vector) const
Coord inet::Rotation::rotateVectorCounterClockwise ( const Coord vector) const

Referenced by inet::physicallayer::DielectricObstacleLoss::computeObjectLoss(), and inet::physicallayer::IdealObstacleLoss::isObstacle().

67 {
69 }
Coord matrixTransposeMultiplication(const double matrix[3][3], const Coord &vector) const
Definition: Rotation.cc:79
double rotationMatrix[3][3]
Definition: Rotation.h:32

Member Data Documentation

double inet::Rotation::rotationMatrix[3][3]
protected

The documentation for this class was generated from the following files: