• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 10609521019

29 Aug 2024 05:56AM UTC coverage: 12.113% (-0.03%) from 12.138%
10609521019

Pull #3847

github

alex-w
[SSE] Add info for total candidates for addiing...
Pull Request #3847: Threaded planet computation (and a few more speedups)

30 of 686 new or added lines in 51 files covered. (4.37%)

41 existing lines in 18 files now uncovered.

14434 of 119159 relevant lines covered (12.11%)

19024.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/Satellites/src/gsatellite/gSatTEME.cpp
1
/***************************************************************************
2
 * Name: gSatTEME.cpp
3
 *
4
 * Description: gSatTEME class implementation.
5
 *              This class abstract all the SGP4 complexity. It uses the
6
 *              David. A. Vallado code for SGP4 Calculation.
7
 *
8
 * Reference:
9
 *              Revisiting Spacetrack Report #3 AIAA 2006-6753
10
 *              Vallado, David A., Paul Crawford, Richard Hujsak, and T.S.
11
 *              Kelso, "Revisiting Spacetrack Report #3,"
12
 *              presented at the AIAA/AAS Astrodynamics Specialist
13
 *              Conference, Keystone, CO, 2006 August 21-24.
14
 *              https://celestrak.org/publications/AIAA/2006-6753/
15
 ***************************************************************************/
16

17
/***************************************************************************
18
 *   Copyright (C) 2004 by J.L. Canales                                    *
19
 *   ph03696@homeserver                                                    *
20
 *                                                                         *
21
 *   This program is free software; you can redistribute it and/or modify  *
22
 *   it under the terms of the GNU General Public License as published by  *
23
 *   the Free Software Foundation; either version 2 of the License, or     *
24
 *   (at your option) any later version.                                   *
25
 *                                                                         *
26
 *   This program is distributed in the hope that it will be useful,       *
27
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
28
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
29
 *   GNU General Public License for more details.                          *
30
 *                                                                         *
31
 *   You should have received a copy of the GNU General Public License     *
32
 *   along with this program; if not, write to the                         *
33
 *   Free Software Foundation, Inc.,                                       *
34
 *   51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.             *
35
 ***************************************************************************/
36

37
// GKepFile
38
#include "gSatTEME.hpp"
39
//#include <iostream>
40
//#include <iomanip>
41
#include <math.h>
42

43
#include "mathUtils.hpp"
44
#include "sgp4io.h"
45

46
#define CONSTANTS_SET wgs84
47
#define TYPERUN_SET   'c'
48
#define OPSMODE_SET   'i'
49
#define TYPEINPUT_SET 'm'
50

51
#define LATITUDE  0
52
#define LONGITUDE 1
53
#define ALTITUDE  2
54

55
// Constructors
56
gSatTEME::gSatTEME(const char *pstrName, char *pstrTleLine1, char *pstrTleLine2)
×
57
{
58
        double startmfe, stopmfe, deltamin; // dummies
59

60
        m_SatName = pstrName;
×
61

62
        //set gravitational constants
63
        getgravconst(CONSTANTS_SET, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2);
×
64

65
        //Parsing TLE_Files and sat variables setting
66
        twoline2rv(pstrTleLine1, pstrTleLine2, TYPERUN_SET, TYPEINPUT_SET, OPSMODE_SET, CONSTANTS_SET,
×
67
                   startmfe, stopmfe, deltamin, satrec);
×
68

69
        // call the propagator to get the initial state vector value
70
        sgp4(CONSTANTS_SET, satrec,  0.0, m_Position.v,  m_Vel.v);
×
71
}
×
72

73
void gSatTEME::setEpoch(gTime ai_time)
×
74
{
75
        gTime     kepEpoch(satrec.jdsatepoch);
×
76
        gTimeSpan tSince = ai_time - kepEpoch;
×
77

78
        double dtsince = tSince.getDblSeconds()/KSEC_PER_MIN;
×
79
        // call the propagator to get the initial state vector value
80
        sgp4(CONSTANTS_SET, satrec,  dtsince, m_Position.v,  m_Vel.v);
×
81

82
        m_SubPoint    = computeSubPoint( ai_time);
×
83
}
×
84

85
void gSatTEME::setMinSinceKepEpoch(double ai_minSinceKepEpoch)
×
86
{
87
        gTimeSpan tSince( ai_minSinceKepEpoch/KMIN_PER_DAY);
×
88
        gTime     Epoch(satrec.jdsatepoch);
×
89
        Epoch += tSince;
×
90
        // call the propagator to get the initial state vector value
91
        sgp4(CONSTANTS_SET, satrec,  ai_minSinceKepEpoch, m_Position.v,  m_Vel.v);
×
92

93
        m_SubPoint    = computeSubPoint( Epoch);
×
94
}
×
95

96
Vec3d gSatTEME::computeSubPoint(gTime ai_Time)
×
97
{
98
        Vec3d resultVector; // (0) Latitude, (1) Longitude, (2) altitude
×
99

NEW
100
        const double theta = atan2(m_Position[1], m_Position[0]); // radians
×
101
        resultVector[ LONGITUDE] = fmod((theta - ai_Time.toThetaGMST()), 2.*M_PI);  //radians
×
102

103

NEW
104
        const double r = std::sqrt(Sqr(m_Position[0]) + Sqr(m_Position[1]));
×
NEW
105
        const double e2 = __f*(2. - __f);
×
UNCOV
106
        resultVector[ LATITUDE] = atan2(m_Position[2],r); /*radians*/
×
107

108
        double phi, c;
109
        do
110
        {
111
                phi = resultVector[ LATITUDE];
×
112
                c = 1./std::sqrt(1. - e2*Sqr(sin(phi)));
×
113
                resultVector[ LATITUDE] = atan2(m_Position[2] + EARTH_RADIUS*c*e2*sin(phi),r);
×
114
        }
115
        while(fabs(resultVector[ LATITUDE] - phi) >= 1E-10);
×
116

117
        resultVector[ ALTITUDE] = r/cos(resultVector[ LATITUDE]) - EARTH_RADIUS*c;/*kilometers*/
×
118

119
        if(resultVector[ LATITUDE] > (M_PI/2.0)) resultVector[ LATITUDE] -= 2.*M_PI;
×
120

121
        resultVector[LATITUDE]  *= M_180_PI;
×
122
        resultVector[LONGITUDE] *= M_180_PI;
×
123
        if(resultVector[LONGITUDE] < -180.0) resultVector[LONGITUDE] += 360;
×
124
        else if(resultVector[LONGITUDE] > 180.0) resultVector[LONGITUDE] -= 360;
×
125

126
        return resultVector;
×
127
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc