Rotation.h

Go to the documentation of this file.
00001 
00002 
00010 /*  \todo Implement Gibbs vector representation
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 // Prototype definitions of classes in Rotation Toolbox
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     // DCM CONSTROCTURS
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     // DCM MUTATORS
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     // DCM INSPECTORS
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     // DCM OPERATORS
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 // end of DirectionCosineMatrix
00207 
00209 
00225 class ModifiedRodriguezParameters:public Vector
00226 {
00227 public:
00228     // MRP CONSTRUCTORS
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     // MRP MUTATORS
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     // MRP INSPECTORS
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     // MRP OPERATORS
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     // end of MRPOperators
00282 private:
00284     bool m_AutoSwitch;
00285 };
00286 // end of ModifiedRodriguezParameters
00287 
00289 
00301 class Quaternion:public Vector
00302 {
00303 public:
00304     // QUATERNION CONSTRUCTORS
00305     Quaternion();
00306 
00307     Quaternion(double _q1, double _q2, double _q3, double _q4);
00308 
00309 //    Quaternion(const Matrix& _qMatrix);
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     // QUATERNION MUTATORS
00322     void Set(const Quaternion& _qIn);
00323 
00324     void Set(double _q1, double _q2, double _q3, double _q4);
00325 
00326 //    void Set(const Matrix& _qMatrix);
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     // QUATERNION INSPECTORS
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     // QUATERNION OPERATORS
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 // end of Quaternion
00360 
00362 
00398 class Rotation
00399 {
00400 public:
00401     // ROTATION CONSTRUCTORS
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     // ROTATION MUTATORS
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     // end of RotationMutators
00436 
00437     // ROTATION INSPECTORS
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     // ROTATION OPERATORS
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     // end of RotationOperators
00463 
00464 private:
00466         Quaternion m_quaternion;
00467         
00469         RotationSense m_RotationSense;
00470 
00471 };
00472 }
00473 
00474 #endif 
00475 /*!***************************************************************************
00476 *       $Log: Rotation.h,v $
00477 *       Revision 1.17  2003/05/22 03:03:38  nilspace
00478 *       Update documentation, and changed all angles to use Angle type.
00479 *       
00480 *       Revision 1.16  2003/05/21 22:18:05  nilspace
00481 *       Moved the documentation to the implementation file.
00482 *       
00483 *       Revision 1.15  2003/05/20 17:53:51  nilspace
00484 *       Updated comments.
00485 *       
00486 *       Revision 1.14  2003/05/13 19:45:10  nilspace
00487 *       Updated comments.
00488 *       
00489 *       Revision 1.13  2003/04/28 14:16:26  nilspace
00490 *       Moved all function definitions out of header file into implementation file.
00491 *       
00492 *       Revision 1.12  2003/04/27 20:41:10  nilspace
00493 *       Encapsulated the rotation library into the namespace O_SESSAME.
00494 *       
00495 *       Revision 1.11  2003/04/23 14:56:18  simpliciter
00496 *       Clarified comments on quaternions (automatic normalization) and
00497 *       outputting rotations (can't do it).
00498 *       
00499 *       Revision 1.10  2003/04/22 21:59:58  nilspace
00500 *       Fixed Quaternion::Set(DCM) so it evaluates correctly.
00501 *       Implemented Rotation::operator-()
00502 *       
00503 *       Revision 1.9  2003/04/22 19:36:03  nilspace
00504 *       Various bug fixes to DCM & quaternion conversions. Added DirectionCosineMatrix Normalize().
00505 *       
00506 *       Revision 1.8  2003/04/22 16:03:11  nilspace
00507 *       Updated MRP::Set(Quaternion) to correctly set.
00508 *       
00509 *       Revision 1.7  2003/04/10 17:25:52  nilspace
00510 *       changelog
00511 *       
00512 *       Revision 1.6  2003/04/08 23:02:27  nilspace
00513 *       Added Rotation Sense, or "Handedness". Defaults to RIGHT_HAND
00514 *       
00515 *       Revision 1.5  2003/03/27 20:22:27  nilspace
00516 *       Added GetRotation() function.
00517 *       Fixed Quaternion.Set(Quaternion) function.
00518 *       Added RotationType enum.
00519 *       Made sure to normalize the Quaternions for all the Set() functions.
00520 *       
00521 *       Revision 1.4  2003/03/25 02:37:36  nilspace
00522 *       Added quaternion matrix set and constructor.
00523 *       Added Rotation generalized matrix set to check for quaternion.
00524 *       
00525 *       Revision 1.3  2003/03/04 17:36:20  nilspace
00526 *       Added CVS tags for documenting uploads. Also chmod'd to not be executable.
00527 *       
00528 *       Revision 1.1  2003/02/27 18:37:26  nilspace
00529 *       Initial submission of Attitude class implementation.
00530 *       
00531 *
00532 ******************************************************************************/

Generated on Wed Aug 6 12:58:51 2003 for Open-Sessame Framework by doxygen1.3