00001
00002
00010
00011
00013
00014 #ifndef __OSESSAME_ROTATION_H__
00015 #define __OSESSAME_ROTATION_H__
00016 #include <math.h>
00017 #include "Matrix.h"
00018 #include "MathUtils.h"
00019 using namespace O_SESSAME;
00020
00021 namespace O_SESSAME {
00022
00023 class Quaternion;
00024 class DirectionCosineMatrix;
00025 class ModifiedRodriguezParameters;
00026 class Rotation;
00027
00029
00063 const int QUATERNION_SIZE = 4;
00065 const int MRP_SIZE = 3;
00067 const int DCM_SIZE = 3;
00069 const int EULERAXIS_SIZE = 3;
00071 const int EULERANGLES_SIZE = 3;
00072
00074 enum RotationType{DCM_Type, EulerAngle_Type, EulerAxisAngle_Type, MRP_Type, Quaternion_Type};
00075
00077 enum RotationSense{LEFT_HAND = -1, RIGHT_HAND = 1};
00078
00081
00082
00138 class DirectionCosineMatrix:public Matrix
00139 {
00140 public:
00141
00142
00143 DirectionCosineMatrix();
00144
00145 DirectionCosineMatrix(const DirectionCosineMatrix& _DCM);
00146
00147 DirectionCosineMatrix(const Matrix& _DCM);
00148
00149 DirectionCosineMatrix(const Vector& _EulerAngles, const int& _Sequence);
00150
00151 DirectionCosineMatrix(const Vector& _EulerAxis, const Angle& _EulerAngle);
00152
00153 DirectionCosineMatrix(const Angle& _Angle1, const Angle& _Angle2, const Angle& _Angle3, const int& _Sequence);
00154
00155 DirectionCosineMatrix(const ModifiedRodriguezParameters& _MRP);
00156
00157 DirectionCosineMatrix(const Quaternion& _quat);
00158
00159 virtual ~DirectionCosineMatrix();
00160
00161
00162 void Set(const DirectionCosineMatrix& _DCM);
00163
00164 void Set(const Matrix& _DCM);
00165
00166 void Set(const Vector& _EulerAngles, const int& _Sequence);
00167
00168 void Set(const Angle& _Angle1, const Angle& _Angle2, const Angle& _Angle3, const int& _Sequence);
00169
00170 void Set(const Vector& _EulerAxis, const Angle& _EulerAngle);
00171
00172 void Set(const ModifiedRodriguezParameters& _MRP);
00173
00174 void Set(const Quaternion& _qIn);
00175
00176
00177 Vector GetEulerAngles(const int& _Sequence) const;
00178
00179 void GetEulerAxisAngle(Vector& _EulerAxis, Angle& _EulerAngle) const;
00180
00181 ModifiedRodriguezParameters GetMRP() const;
00182
00183 Quaternion GetQuaternion() const;
00184
00185
00186 void Normalize();
00187
00188 DirectionCosineMatrix operator+ (const DirectionCosineMatrix& _DCM2) const;
00189
00190 DirectionCosineMatrix operator- (const DirectionCosineMatrix& _DCM2) const;
00191
00192 inline DirectionCosineMatrix operator* (DirectionCosineMatrix _DCM2) const;
00193
00194 inline Vector operator* (const Vector& _vec) const;
00195
00196 inline DirectionCosineMatrix operator~ ();
00197
00198 };
00199
00200
00201 DirectionCosineMatrix R1(const Angle& _Angle);
00202
00203 DirectionCosineMatrix R2(const Angle& _Angle);
00204
00205 DirectionCosineMatrix R3(const Angle& _Angle);
00206
00207
00209
00225 class ModifiedRodriguezParameters:public Vector
00226 {
00227 public:
00228
00229 ModifiedRodriguezParameters();
00230
00231 ModifiedRodriguezParameters(const ModifiedRodriguezParameters& _MRP);
00232
00233 ModifiedRodriguezParameters(const double& _s1, const double& _s2, const double& _s3);
00234
00235 ModifiedRodriguezParameters(const Vector& _sVector);
00236
00237 ModifiedRodriguezParameters(const DirectionCosineMatrix& _DCM);
00238
00239 ModifiedRodriguezParameters(const Vector& _Angles, const int& _Sequence);
00240
00241 ModifiedRodriguezParameters(const Vector& _EulerAxis, const Angle& _EulerAngle);
00242
00243 ModifiedRodriguezParameters(const Quaternion& _qIN);
00244
00245
00246 void Set(const ModifiedRodriguezParameters& _MRP);
00247
00248 void Set(const double& _s1, const double& _s2, const double& _s3);
00249
00250 void Set(const Vector& _sVector);
00251
00252 void Set(const DirectionCosineMatrix& _DCM);
00253
00254 void Set(const Vector& _EulerAngles, const int& _Sequence);
00255
00256 void Set(const Angle& _Angle1, const Angle& _Angle2, const Angle& _Angle3, const int& _Sequence);
00257
00258 void Set(const Vector& _EulerAxis, const Angle& _EulerAngle);
00259
00260 void Set(const Quaternion& _qIN);
00261
00262
00263 DirectionCosineMatrix GetDCM() const;
00264
00265 Vector GetEulerAngles(int _Sequence) const;
00266
00267 void GetEulerAxisAngle(Vector& _EulerAxis, Angle& _EulerAngle) const;
00268
00269 Quaternion GetQuaternion() const;
00270
00271
00272 void Switch(int _SwitchThreshold = 1);
00273
00274 void AutoSwitch(bool _SwitchBoolean = false);
00275
00276 ModifiedRodriguezParameters ShadowSet() const;
00277
00278 ModifiedRodriguezParameters operator+ (const ModifiedRodriguezParameters& _MRP2) const;
00279
00280 ModifiedRodriguezParameters operator- (const ModifiedRodriguezParameters& _MRP2) const;
00281
00282 private:
00284 bool m_AutoSwitch;
00285 };
00286
00287
00289
00301 class Quaternion:public Vector
00302 {
00303 public:
00304
00305 Quaternion();
00306
00307 Quaternion(double _q1, double _q2, double _q3, double _q4);
00308
00309
00310
00311 Quaternion(const Vector& _qVector);
00312
00313 Quaternion(const DirectionCosineMatrix& _DCM);
00314
00315 Quaternion(const Vector& _EulerAngles, const int& _Sequence);
00316
00317 Quaternion(const Vector& _EulerAxis, const Angle& _EulerAngle);
00318
00319 Quaternion(const ModifiedRodriguezParameters& _MRP);
00320
00321
00322 void Set(const Quaternion& _qIn);
00323
00324 void Set(double _q1, double _q2, double _q3, double _q4);
00325
00326
00327
00328 void Set(const Vector& _qVector);
00329
00330 void Set(const DirectionCosineMatrix& _DCM);
00331
00332 void Set(const Vector& _EulerAngles, const int& _Sequence);
00333
00334 void Set(const Vector& _EulerAxis, const Angle& _EulerAngle);
00335
00336 void Set(const ModifiedRodriguezParameters& _MRP);
00337
00338
00339 DirectionCosineMatrix GetDCM() const;
00340
00341 Vector GetEulerAngles(const int& _Sequence) const;
00342
00343 Vector GetEulerAxisAngle(Vector& _EulerAxis, Angle& _EulerAngle) const;
00344
00345 Vector GetEulerAxisAngle() const;
00346
00347 ModifiedRodriguezParameters GetMRP() const;
00348
00349
00350 void Normalize();
00351
00352 Quaternion operator+ (const Quaternion& _quat2) const;
00353
00354 Quaternion operator- (const Quaternion& _quat2) const;
00355
00356 private:
00357
00358 };
00359
00360
00362
00398 class Rotation
00399 {
00400 public:
00401
00402 Rotation();
00403
00404 Rotation(const Matrix& _inMatrix);
00405
00406 Rotation(const DirectionCosineMatrix& _DCM);
00407
00408 Rotation(const Vector& _Angles, const int& _Sequence);
00409
00410 Rotation(const Angle& _Angle1, const Angle& _Angle2, const Angle& _Angle3, const int& _Sequence);
00411
00412 Rotation(const Vector& _Axis, const Angle& _Angle);
00413
00414 Rotation(const ModifiedRodriguezParameters& _MRP);
00415
00416 Rotation(const Quaternion& _quat);
00417
00418 virtual ~Rotation();
00419
00420
00421 void Set(const Matrix& _inMatrix);
00422
00423 void Set(const DirectionCosineMatrix& _DCM);
00424
00425 void Set(const Vector& _Angles, const int& _Sequence);
00426
00427 void Set(const Angle& _Angle1, const Angle& _Angle2, const Angle& _Angle3, const int& _Sequence);
00428
00429 void Set(const Vector& _Axis, const Angle& _Angle);
00430
00431 void Set(const ModifiedRodriguezParameters& _MRP);
00432
00433 void Set(const Quaternion& _quat);
00434
00435
00436
00437
00438 DirectionCosineMatrix GetDCM() const;
00439
00440 Vector GetEulerAngles(const int& _Sequence) const;
00441
00442 Vector GetEulerAxisAngle(Vector& _EulerAxis, Angle& _EulerAngle) const;
00443
00444 Vector GetEulerAxisAngle() const;
00445
00446 ModifiedRodriguezParameters GetMRP() const;
00447
00448 Quaternion GetQuaternion() const;
00449
00450 Vector GetRotation(const RotationType& _type, const int& _Sequence = 123) const;
00451
00452
00453 Rotation Rotation::operator* (const Rotation& _rot2) const;
00454
00455 Vector Rotation::operator* (const Vector& _vec) const;
00456
00457 Rotation Rotation::operator~ () const;
00458
00459 Rotation Rotation::operator+ (const Rotation& _rot2) const;
00460
00461 Rotation Rotation::operator- (const Rotation& _rot2) const;
00462
00463
00464 private:
00466 Quaternion m_quaternion;
00467
00469 RotationSense m_RotationSense;
00470
00471 };
00472 }
00473
00474 #endif
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532