00001
00002
00008
00009
00011
00012 #include <iostream.h>
00013 #include <iomanip.h>
00014 #include "Rotation.h"
00015 #include "Matrix.h"
00016 #include "ASCIIConverter.h"
00017 #include "BinaryConverter.h"
00018 #include "MatrixConversionForm.h"
00019
00020 using namespace O_SESSAME;
00021
00022 int main()
00023 {
00024 Quaternion qInit(0,0,0,1);
00025 Rotation rotInit(qInit);
00026 cout << "q - R(q) = " << qInit - rotInit.GetQuaternion() << endl;
00027 cout << "R(q)->DCM = " << rotInit.GetDCM() << endl;
00028 Rotation rot2(Quaternion(0.5,0.5,0.5,0.5));
00029 cout << "R(q(0.5,0.5,0.5,0.5)) = " << rot2.GetDCM() << endl;
00030
00031 Rotation Rot321(Deg2Rad(10),Deg2Rad(0.1),Deg2Rad(-5),321);
00032 cout << "R(10, 0.1, -5, 321) (degs) = " << Rot321.GetDCM() << endl;
00033 cout << "R(10, 0.1, -5, 321) (degs) = " << Rot321.GetDCM().GetQuaternion().GetDCM() << endl;
00034
00035
00036 cout << "R1(-2)" << setprecision(15) << R1(Deg2Rad(-2)) << endl;
00037 cout << "R2(-5)" << setprecision(15) << R2(Deg2Rad(-5)) << endl;
00038 cout << "R3(-10)" << setprecision(15) << R3(Deg2Rad(10)) << endl;
00039 DirectionCosineMatrix DCM1(Deg2Rad(10),Deg2Rad(0.1),Deg2Rad(-5),321);
00040 cout << "DCM(10, 0.1, -5, 321) (degs) = " << endl << setprecision(15) << DCM1 << endl;
00041 Vector xAxis(3);
00042 xAxis(1) = 1;
00043 cout << ~xAxis << " -> " << ~(rot2 * xAxis) << endl;
00044 cout << ~xAxis << " -> " << ~(rotInit * xAxis) << endl;
00045
00046
00047 ModifiedRodriguezParameters mrp1(0,0.2, -0.3);
00048 cout << "mrp1(0,0.2, -0.3): " << ~mrp1;
00049 cout << "sigmaSq = " << (~mrp1 * mrp1);
00050 cout << "mrp1->Quat: " << ~mrp1.GetQuaternion();
00051
00052 Rotation rot3(mrp1.GetQuaternion());
00053 cout << "Rot3->Quat->MRP: " << ~rot3.GetQuaternion().GetMRP();
00054 cout << "Rot3->MRP: " << ~rot3.GetMRP() << endl;
00055 cout << "Rot3->Quat: " << ~rot3.GetQuaternion();
00056 cout << "Rot3.DCM->Quaternion: " << ~rot3.GetDCM().GetQuaternion() << endl;
00057 cout << "mrp1->DCM: " << endl << mrp1.GetDCM() << endl;
00058 cout << "mrp->Quat->DCM: " << endl << mrp1.GetQuaternion().GetDCM() << endl;
00059 cout << "Rot3.DCM: " << endl << rot3.GetDCM() << endl;
00060
00061
00062 MatrixConversionForm convForm;
00063 ASCIIConverter rotOutput("rotationSave.txt");
00064 convForm.SetMatrix(rot3.GetDCM());
00065 rotOutput.Export(convForm);
00066
00067 ASCIIConverter rotInput("rotationSave.txt");
00068 rotInput.Import(convForm);
00069 cout << "Imported Matrix: " << convForm.GetMatrix();
00070 Rotation rotImport(convForm.GetMatrix());
00071 cout << "Rot3_Import MRP: " << ~rotImport.GetMRP();
00072
00073
00074 MatrixConversionForm binConvForm;
00075 convForm.SetMatrix(rot3.GetDCM());
00076 BinaryConverter rotOutputBIN("rotationSave");
00077 convForm.SetMatrix(rot3.GetDCM());
00078 rotOutputBIN.Export(convForm);
00079
00080 BinaryConverter rotInputBIN("rotationSave");
00081 rotInputBIN.Import(binConvForm);
00082 cout << "Imported Matrix: " << binConvForm.GetMatrix();
00083 Rotation rotImportBin(binConvForm.GetMatrix());
00084 cout << "Rot3_Import Binary MRP: " << ~rotImportBin.GetMRP();
00085 return 0;
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100