Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59d658d

Browse files
authored
Merge pull request#2 from wojciech-graj/master
Small C Improvements
2 parents4283a5b +fba1e16 commit59d658d

File tree

4 files changed

+69
-74
lines changed

4 files changed

+69
-74
lines changed

‎src/c/SGP4.c

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
* ---------------------------------------------------------------- */
5959

6060

61-
62-
61+
62+
6363
/* -----------------------------------------------------------------------------
6464
*
6565
* procedure dpper
@@ -148,7 +148,7 @@
148148
sinip,sinop,sinzf,sis,sll,sls,xls,
149149
xnoh,zf,zm,zel,zes,znl,zns;
150150

151-
151+
152152
/* ---------------------- constants ----------------------------- */
153153
zns=1.19459e-5;
154154
zes=0.01675;
@@ -870,11 +870,11 @@
870870
intiretn;
871871
doubledelt,ft,theta,x2li,x2omi,xl,xldot,xnddt,xndt,xomi,g22,g32,
872872
g44,g52,g54,fasx2,fasx4,fasx6,rptim,step2,stepn,stepp;
873-
873+
874874
xndt=0;
875875
xnddt=0;
876876
xldot=0;
877-
877+
878878
fasx2=0.13130908;
879879
fasx4=2.8843198;
880880
fasx6=0.37448087;
@@ -986,7 +986,7 @@
986986
}
987987
}// while iretn = 381
988988

989-
989+
990990
rec->nm=rec->xni+xndt*ft+xnddt*ft*ft*0.5;
991991
xl=rec->xli+xldot*ft+xndt*ft*ft*0.5;
992992
if (rec->irez!=1)
@@ -1065,7 +1065,7 @@
10651065
// sgp4fix use old way of finding gst
10661066
doubleds70;
10671067
doublets70,tfrac,c1,thgr70,fk5r,c1p2p;
1068-
1068+
10691069
/* ----------------------- earth constants ---------------------- */
10701070
// sgp4fix identify constants and allow alternate values
10711071
// only xke and j2 are used here so pass them in directly
@@ -1205,17 +1205,17 @@
12051205
boolsgp4init (charopsmode,ElsetRec*satrec)
12061206
{
12071207
/* --------------------- local variables ------------------------ */
1208-
1208+
12091209
doublecc1sq,
12101210
cc2,cc3,coef,coef1,cosio4,
12111211
eeta,etasq,perige,pinvsq,psisq,qzms24,
12121212
sfour,tc,temp,temp1,temp2,temp3,tsi,xpidot,
12131213
xhdot1,qzms2t,ss,x2o3,r[3],v[3],
12141214
delmotemp,qzms2ttemp,qzms24temp;
1215-
1216-
1215+
1216+
12171217
doubleepoch= (satrec->jdsatepoch+satrec->jdsatepochF)-2433281.5;
1218-
1218+
12191219
/* ------------------------ initialization --------------------- */
12201220
// sgp4fix divisor for divide by zero check on inclination
12211221
// the old check used 1.0 + cos(pi-1.0e-9), but then compared it to
@@ -1281,9 +1281,9 @@
12811281
satrec->t=0.0;
12821282

12831283
// sgp4fix remove satn as it is not needed in initl
1284-
1284+
12851285
initl(epoch,satrec);
1286-
1286+
12871287
satrec->a=pow(satrec->no_unkozai*satrec->tumin, (-2.0 /3.0));
12881288
satrec->alta=satrec->a* (1.0+satrec->ecco)-1.0;
12891289
satrec->altp=satrec->a* (1.0-satrec->ecco)-1.0;
@@ -1382,15 +1382,15 @@
13821382
satrec->inclm=satrec->inclo;
13831383

13841384
dscom(epoch,satrec->ecco,satrec->argpo,tc,satrec->inclo,satrec->nodeo,satrec->no_unkozai,satrec);
1385-
1386-
1385+
1386+
13871387
satrec->ep=satrec->ecco;
13881388
satrec->inclp=satrec->inclo;
13891389
satrec->nodep=satrec->nodeo;
13901390
satrec->argpp=satrec->argpo;
13911391
satrec->mp=satrec->mo;
13921392

1393-
1393+
13941394
dpper(satrec->e3,satrec->ee2,satrec->peo,satrec->pgho,
13951395
satrec->pho,satrec->pinco,satrec->plo,satrec->se2,
13961396
satrec->se3,satrec->sgh2,satrec->sgh3,satrec->sgh4,
@@ -1412,7 +1412,7 @@
14121412
satrec->argpm=0.0;
14131413
satrec->nodem=0.0;
14141414
satrec->mm=0.0;
1415-
1415+
14161416
dsinit(tc,xpidot,satrec);
14171417
}
14181418

@@ -1437,8 +1437,8 @@
14371437
/* finally propogate to zero epoch to initialize all others. */
14381438
// sgp4fix take out check to let satellites process until they are actually below earth surface
14391439
// if(satrec->error == 0)
1440-
1441-
1440+
1441+
14421442
sgp4(satrec,0.0,r,v);
14431443

14441444
satrec->init='n';
@@ -1540,7 +1540,7 @@
15401540
double*r,double*v
15411541
)
15421542
{
1543-
1543+
15441544
doubleaxnl,aynl,betal,cnod,
15451545
cos2u,coseo1,cosi,cosip,cosisq,cossu,cosu,
15461546
delm,delomg,ecose,el2,eo1,
@@ -1553,7 +1553,7 @@
15531553
xinc,xincp,xl,xlm,
15541554
xmdf,xmx,xmy,nodedf,xnode,tc,
15551555
x2o3,vkmpersec,delmtemp;
1556-
1556+
15571557
intktr;
15581558

15591559
/* ------------------ set mathematical constants --------------- */
@@ -1589,7 +1589,7 @@
15891589
t3=0;
15901590
t4=0;
15911591
mrt=0;
1592-
1592+
15931593
if (satrec->isimp!=1)
15941594
{
15951595
delomg=satrec->omgcof*satrec->t;
@@ -1609,15 +1609,15 @@
16091609
templ=templ+satrec->t3cof*t3+t4* (satrec->t4cof+satrec->t*satrec->t5cof);
16101610
}
16111611

1612-
1612+
16131613
tc=0;
16141614
satrec->nm=satrec->no_unkozai;
16151615
satrec->em=satrec->ecco;
16161616
satrec->inclm=satrec->inclo;
16171617
if (satrec->method=='d')
16181618
{
16191619
tc=satrec->t;
1620-
dspace(tc,satrec);
1620+
dspace(tc,satrec);
16211621
}// if method = d
16221622

16231623
if (satrec->nm <=0.0)
@@ -1626,7 +1626,7 @@
16261626
// sgp4fix add return
16271627
return FALSE;
16281628
}
1629-
1629+
16301630
satrec->am=pow((satrec->xke /satrec->nm),x2o3)*tempa*tempa;
16311631
satrec->nm=satrec->xke /pow(satrec->am,1.5);
16321632
satrec->em=satrec->em-tempe;
@@ -1683,9 +1683,9 @@
16831683
satrec->sl2,satrec->sl3,satrec->sl4,satrec->t,
16841684
satrec->xgh2,satrec->xgh3,satrec->xgh4,satrec->xh2,
16851685
satrec->xh3,satrec->xi2,satrec->xi3,satrec->xl2,
1686-
satrec->xl3,satrec->xl4,satrec->zmol,satrec->zmos,
1686+
satrec->xl3,satrec->xl4,satrec->zmol,satrec->zmos,
16871687
'n',satrec,satrec->operationmode);
1688-
1688+
16891689
xincp=satrec->inclp;
16901690
if (xincp<0.0)
16911691
{
@@ -1893,13 +1893,6 @@
18931893

18941894
}// getgravconst
18951895

1896-
1897-
doublefmod(doublenumer,doubledenom)
1898-
{
1899-
longtquot= (long)floor(numer/denom);
1900-
returnnumer-tquot*denom;
1901-
}
1902-
19031896
/* -----------------------------------------------------------------------------
19041897
*
19051898
* function gstime
@@ -1941,7 +1934,7 @@
19411934

19421935
returntemp;
19431936
}// gstime
1944-
1937+
19451938
/* -----------------------------------------------------------------------------
19461939
*
19471940
* procedure jday

‎src/c/SGP4.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef__sgp4header__
2-
#define__sgp4header__
2+
#define__sgp4header__
33

44
#definewgs72old 1
55
#definewgs72 2
@@ -9,16 +9,20 @@
99
#definetwopi (2.0*pi)
1010
#definedeg2rad (pi/180.0)
1111

12+
#ifdef__STDC_VERSION__
13+
#include<stdbool.h>
14+
#else
1215
typedefintbool;
16+
#endif
1317
#defineTRUE 1
1418
#defineFALSE 0
1519

1620
/**
1721
* This class implements the elsetrec data type from Vallado's SGP4 code.
18-
*
22+
*
1923
* From SGP4.h
2024
* #define SGP4Version "SGP4 Version 2016-03-09"
21-
*
25+
*
2226
* @author aholinch
2327
*
2428
*/
@@ -30,7 +34,7 @@ typedef struct ElsetRec {
3034
interror;
3135
charoperationmode;
3236
charinit;
33-
charmethod;
37+
charmethod;
3438
doublea;
3539
doublealtp;
3640
doublealta;
@@ -47,17 +51,17 @@ typedef struct ElsetRec {
4751
doubleargpo;
4852
doublemo;
4953
doubleno_kozai;
50-
54+
5155
// sgp4fix add new variables from tle
5256
charclassification;
5357
charintldesg[12];
5458
intephtype;
5559
longelnum;
5660
longrevnum;
57-
61+
5862
// sgp4fix add unkozai'd variable
5963
doubleno_unkozai;
60-
64+
6165
// sgp4fix add singly averaged variables
6266
doubleam;
6367
doubleem;
@@ -67,23 +71,23 @@ typedef struct ElsetRec {
6771
doublemm;
6872
doublenm;
6973
doublet;
70-
74+
7175
// sgp4fix add constant parameters to eliminate mutliple calls during execution
7276
doubletumin;
7377
doublemu;
7478
doubleradiusearthkm;
75-
doublexke;
79+
doublexke;
7680
doublej2;
7781
doublej3;
7882
doublej4;
7983
doublej3oj2;
80-
81-
// Additional elements to capture relevant TLE and object information:
84+
85+
// Additional elements to capture relevant TLE and object information:
8286
longdia_mm;// RSO dia in mm
8387
doubleperiod_sec;// Period in seconds
84-
charactive;// "Active S/C" flag (0=n, 1=y)
85-
charnot_orbital;// "Orbiting S/C" flag (0=n, 1=y)
86-
doublercs_m2;// "RCS (m^2)" storage
88+
charactive;// "Active S/C" flag (0=n, 1=y)
89+
charnot_orbital;// "Orbiting S/C" flag (0=n, 1=y)
90+
doublercs_m2;// "RCS (m^2)" storage
8791

8892
// temporary variables because the original authors call the same method with different variables
8993
doubleep;
@@ -185,14 +189,14 @@ typedef struct ElsetRec {
185189
doubleday;
186190
doubleemsq;
187191
doublegam;
188-
doublertemsq;
192+
doublertemsq;
189193
doubles1;
190194
doubles2;
191195
doubles3;
192196
doubles4;
193197
doubles5;
194198
doubles6;
195-
doubles7;
199+
doubles7;
196200
doubless1;
197201
doubless2;
198202
doubless3;
@@ -229,7 +233,7 @@ typedef struct ElsetRec {
229233
doublenodem;
230234
doubledndt;
231235
doubleeccsq;
232-
236+
233237
// for initl
234238
doubleainv;
235239
doubleao;
@@ -272,6 +276,4 @@ double gstime(double jdut1);
272276

273277
voidjday(intyear,intmon,intday,inthr,intminute,doublesec,double*jd,double*jdfrac);
274278

275-
doublefmod(doublenumer,doubledenom);
276-
277279
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp