COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
att_test.cpp File Reference
#include "mathlib.h"
#include "convertlib.h"
Include dependency graph for att_test.cpp:

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)
34 {
35 rvector r_a, r_ad;
36 rvector r_b, r_bd;
37 rvector omega_a, omega_b, domega;
38 rmatrix s0_a2b, s1_a2b, s0_b2a, s1_b2a;
39 locstruc loc;
40 int i;
41 double rl, rl2;
42 
43 //set_resdir("/home/cosmos/data");
44 loc.pos.eci.s = loc.pos.eci.v = loc.pos.eci.a = rv_zero();
45 //loc.pos.eci.utc = 55898.085729;
46 /*
47 loc.pos.eci.utc = 55593.41666667;
48 loc.pos.eci.s.col[0] = -1.35425064646195e+006;
49 loc.pos.eci.s.col[1] = 6.79448949176058e+006;
50 loc.pos.eci.s.col[2] = 1.53887448487181e+002;
51 loc.pos.eci.v.col[0] = 9.83318338395099e+002;
52 loc.pos.eci.v.col[1] = 1.95820817667284e+002;
53 loc.pos.eci.v.col[2] = 7.51853092957268e+003;
54 */
55 loc.pos.eci.utc = 55593.417361114;
56 loc.pos.eci.s.col[0] = -1.29236902697246e+006;
57 loc.pos.eci.s.col[1] = 6.79155588127674e+006;
58 loc.pos.eci.s.col[2] = 4.50939536126163e+005;
59 loc.pos.eci.v.col[0] = 1.07865806254567e+003;
60 loc.pos.eci.v.col[1] = -2.93571016435623e+002;
61 loc.pos.eci.v.col[2] = 7.50223303990417e+003;
62 loc.pos.eci.a.col[0] = 1.551240;
63 loc.pos.eci.a.col[1] = -8.151717;
64 loc.pos.eci.a.col[2] = -0.542812;
65 
66 loc.att.icrf.s = q_eye();
67 loc.att.icrf.v = loc.att.icrf.a = rv_zero();
68 pos_eci2geoc(&loc);
69 att_icrf2lvlh(&loc);
70 
71 pos_geoc2eci(&loc);
72 
73 /*
74 loc.pos.geoc.s.col[0] = -6.92811300474276e+006;
75 loc.pos.geoc.s.col[1] = -1.81834522971509e+004;
76 loc.pos.geoc.s.col[2] = -1.35880301329570e+003;
77 loc.pos.geoc.v.col[0] = -5.41067032674325e+000;
78 loc.pos.geoc.v.col[1] = 1.49960794154777e+003;
79 loc.pos.geoc.v.col[2] = 7.51962270141293e+003;
80 */
81 loc.pos.geoc.s.col[0] = -6.91314723731658e+006;
82 loc.pos.geoc.s.col[1] = 7.17245429728969e+004;
83 loc.pos.geoc.s.col[2] = 4.49495629279657e+005;
84 loc.pos.geoc.v.col[0] = 5.04082852450504e+002;
85 loc.pos.geoc.v.col[1] = 1.49550752144134e+003;
86 loc.pos.geoc.v.col[2] = 7.50343144307068e+003;
87 pos_geoc2eci(&loc);
88 
89 r_a = omega_a = rv_one();
90 r_a = rv_smult(5e6,r_a);
91 rl = length_rv(r_a);
92 rl2 = 1./(rl*rl);
93 
94 for (i=0; i<100000; i++)
95  {
96 r_b = rv_mmult(s0_a2b,r_a);
97 r_bd = rv_mmult(s1_a2b,r_a);
98 omega_b = rv_mmult(s0_a2b,omega_a);
99 domega = rv_smult(rl2,rv_cross(r_b,r_bd));
100 omega_b = rv_add(omega_b,domega);
101 //omega_a = rv_sub(omega_b,domega);
102 //omega_a = rv_mmult(s0_b2a,omega_a);
103 
104 r_a = rv_mmult(s0_b2a,r_b);
105 r_ad = rv_mmult(s1_b2a,r_b);
106 omega_a = rv_mmult(s0_b2a,omega_b);
107 domega = rv_smult(rl2,rv_cross(r_a,r_ad));
108 omega_a = rv_add(omega_a,domega);
109 printf("%15g %15g %15g %15g %15g %15g %15g %15g \r",(5e6-r_a.col[0])/5e6,(5e6-r_a.col[1])/5e6,(5e6-r_a.col[2])/5e6,length_rv(r_a)/rl,1.-omega_a.col[0],1.-omega_a.col[1],1.-omega_a.col[2],length_rv(omega_a)/sqrt(3.));
110  }
111 printf("\n");
112 }
rvector rv_add(rvector a, rvector b)
Add two row vectors.
Definition: vector.cpp:299
3 element generic row vector
Definition: vector.h:53
rvector a
Acceleration.
Definition: convertdef.h:167
double utc
UTC of Position.
Definition: convertdef.h:161
int i
Definition: rw_test.cpp:37
rvector a
2nd derivative: Alpha - acceleration
Definition: convertdef.h:483
double length_rv(rvector v)
Length of row vector.
Definition: vector.cpp:748
cartpos geoc
Definition: convertdef.h:739
rvector rv_one()
Row vector of ones.
Definition: vector.cpp:151
rvector v
1st derivative: Omega - angular velocity
Definition: convertdef.h:481
rvector rv_smult(double a, rvector b)
Multiply row vector by scalar.
Definition: vector.cpp:266
int32_t pos_geoc2eci(locstruc *loc)
Convert GEOC to ECI.
Definition: convertlib.cpp:913
rvector s
Location.
Definition: convertdef.h:163
attstruc att
attstruc for this time.
Definition: convertdef.h:883
3x3 element generic matrix
Definition: matrix.h:41
int32_t pos_eci2geoc(locstruc *loc)
Convert ECI to GEOC.
Definition: convertlib.cpp:836
qatt icrf
Definition: convertdef.h:830
rvector rv_zero()
Zero row order vector.
Definition: vector.cpp:107
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
quaternion s
0th derivative: Quaternion
Definition: convertdef.h:479
int32_t att_icrf2lvlh(locstruc *loc)
Definition: convertlib.cpp:1822
double col[3]
Definition: vector.h:55
cartpos eci
Definition: convertdef.h:737
quaternion q_eye()
Identity quaternion.
Definition: vector.cpp:1310
rvector rv_mmult(rmatrix m, rvector v)
Multiply rmatrix by rvector.
Definition: matrix.cpp:41
rvector rv_cross(rvector a, rvector b)
Take cross product of two row vectors.
Definition: vector.cpp:363
Definition: convertdef.h:876
rvector v
Velocity.
Definition: convertdef.h:165