#include <iostream.h>
#include "rotation/Rotation.h"
#include "dynamics/Dynamics.h"
#include "kinematics/Kinematics.h"
#include "dynamics/Attitude.h"
#include "environment/Environment.h"
#include "environment/EarthCentralBody.h"
#include "environment/Gravity.h"
#include "utils/Units.h"
Environment* SetupEnvironment(Attitude &_SpacecraftAttitude)
{
Environment *pEarthEnv = new Environment;
EarthCentralBody *pCBEarth = new EarthCentralBody;
pEarthEnv->SetCentralBody(pCBEarth);
EnvFunction GGTorque(GravityGradientTorque);
cout << "Filling Parameters" << endl;
GGTorque.AddParameter((void*)&(_SpacecraftAttitude.GetAttitude()), 1);
GGTorque.AddParameter((void*)&(_SpacecraftAttitude.GetMOI()), 2);
GGTorque.AddParameter((void*)&(pCBEarth->GetWc(500000)),3);
pEarthEnv->AddTorqueFunction(GGTorque);
return pEarthEnv;
}
int main()
{
Attitude testAttitude;
Rotation rotInit(Quaternion(0.01,0,0,.8));
testAttitude.SetAttitude(rotInit);
Vector AngularVelocity(3);
Vector ControlTorques(3);
AngularVelocity(VectorIndexBase) = 0.1;
ControlTorques(VectorIndexBase) = 0.0;
Matrix MOI = eye(3);
Vector time(2);
time(VectorIndexBase + 0) = 0;
time(VectorIndexBase + 2) = 100;
testAttitude.SetAngularVelocity(AngularVelocity);
testAttitude.SetControlTorques(ControlTorques);
testAttitude.SetMOI(MOI);
testAttitude.SetKinematicsEq(&QuaternionKinematics);
testAttitude.SetDynamicsEq(&QuaternionDynamics);
Environment* pEarth = SetupEnvironment(testAttitude);
testAttitude.SetEnvironment(pEarth);
cout << "Propagating..." << endl;
testAttitude.Propagate(time);
cout << "History: "<< endl << testAttitude.GetHistory();
delete pEarth;
return 0;
}