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

Stellarium / stellarium / 10124913218

27 Jul 2024 04:27PM UTC coverage: 12.208%. First build
10124913218

Pull #3794

github

gzotti
Reduced to max.4 additional threads
Pull Request #3794: Parallelize ephemeris computation with C++ parallelism.

208 of 369 new or added lines in 24 files covered. (56.37%)

14439 of 118271 relevant lines covered (12.21%)

19314.1 hits per line

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

0.0
/src/core/planetsephems/pluto.cpp
1
/*
2
Copyright (C) 2001 Liam Girdwood <liam@nova-ioe.org>
3
Copyright (C) 2003 Fabien Chereau
4
Copyright (C) 2024 Georg Zotti (C++ changes)
5

6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU Library General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10

11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15

16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
19
*/
20

21
#include "pluto.hpp"
22
#include "StelUtils.hpp"
23
#include <array>
24
#include <cmath>
25
#include <execution>
26
#include <numeric>
27

28
#define PLUTO_COEFFS 43
29

30
/*
31
struct pluto_argument
32
{
33
    double J, S, P;
34
};
35

36
struct pluto_longitude
37
{
38
    double A,B;
39
};
40

41
struct pluto_latitude
42
{
43
    double A,B;
44
};
45

46
struct pluto_radius
47
{
48
    double A,B;
49
};
50
*/
51

52
// Combine all in one!
53
struct pluto_data
54
{
55
    double J, S, P, lngA, lngB, latA, latB, radA, radB;
56
};
57

58
static const std::array<struct pluto_data, PLUTO_COEFFS> data = {{
59
//   J  S   P     lngA,        lngB, latA, latB, radA, radB
60
    {0, 0,  1, -19799805, 19850055, -5452852, -14974862,  66865439, 68951812},
61
    {0, 0,  2,    897144, -4954829,  3527812,   1672790, -11827535,  -332538},
62
    {0, 0,  3,    611149,  1211027, -1050748,    327647,   1593179, -1438890},
63
    {0, 0,  4,   -341243,  -189585,   178690,   -292153,    -18444,   483220},
64
    {0, 0,  5,    129287,   -34992,    18650,    100340,    -65977,   -85431},
65
    {0, 0,  6,    -38164,    30893,   -30697,    -25823,     31174,    -6032},
66
    {0, 1, -1,     20442,    -9987,     4878,     11248,     -5794,    22161},
67
    {0, 1,  0,     -4063,    -5071,      226,       -64,      4601,     4032},
68
    {0, 1,  1,     -6016,    -3336,     2030,      -836,     -1729,      234},
69
    {0, 1,  2,     -3956,     3039,       69,      -604,      -415,      702},
70
    {0, 1,  3,      -667,     3572,     -247,      -567,       239,      723},
71
    {0, 2, -2,      1276,      501,      -57,         1,        67,      -67},
72
    {0, 2, -1,      1152,     -917,     -122,       175,      1034,     -451},
73
    {0, 2,  0,       630,    -1277,      -49,      -164,      -129,      504},
74
    {1, -1, 0,      2571,     -459,     -197,       199,       480,     -231},
75
    {1, -1, 1,       899,    -1449,      -25,       217,         2,     -441},
76
    {1, 0, -3,     -1016,     1043,      589,      -248,     -3359,      265},
77
    {1, 0, -2,     -2343,    -1012,     -269,       711,      7856,    -7832},
78
    {1, 0, -1,      7042,      788,      185,       193,        36,    45763},
79
    {1, 0,  0,      1199,     -338,      315,       807,      8663,     8547},
80
    {1, 0,  1,       418,      -67,     -130,       -43,      -809,     -769},
81
    {1, 0,  2,       120,     -274,        5,         3,       263,     -144},
82
    {1, 0,  3,       -60,     -159,        2,        17,      -126,       32},
83
    {1, 0,  4,       -82,      -29,        2,         5,       -35,      -16},
84
    {1, 1, -3,       -36,      -20,        2,         3,       -19,       -4},
85
    {1, 1, -2,       -40,        7,        3,         1,       -15,        8},
86
    {1, 1, -1,       -14,       22,        2,        -1,        -4,       12},
87
    {1, 1,  0,         4,       13,        1,        -1,         5,        6},
88
    {1, 1,  1,         5,        2,        0,        -1,         3,        1},
89
    {1, 1,  3,        -1,        0,        0,         0,         6,       -2},
90
    {2, 0, -6,         2,        0,        0,        -2,         2,        2},
91
    {2, 0, -5,        -4,        5,        2,         2,        -2,       -2},
92
    {2, 0, -4,         4,       -7,       -7,         0,        14,       13},
93
    {2, 0, -3,        14,       24,       10,        -8,       -63,       13},
94
    {2, 0, -2,       -49,      -34,       -3,        20,       136,     -236},
95
    {2, 0, -1,       163,      -48,        6,         5,       273,     1065},
96
    {2, 0,  0,         9,       24,       14,        17,       251,      149},
97
    {2, 0,  1,        -4,        1,       -2,         0,       -25,       -9},
98
    {2, 0,  2,        -3,        1,        0,         0,         9,       -2},
99
    {2, 0,  3,         1,        3,        0,         0,        -8,        7},
100
    {3, 0, -2,        -3,       -1,        0,         1,         2,      -10},
101
    {3, 0, -1,         5,       -3,        0,         0,        19,       35},
102
    {3, 0,  0,         0,        0,        1,         0,        10,        2}
103
}};
104

105

106
/* Transform spheric coordinate in rectangular */
NEW
107
void sphe_to_rect(const double lng, const double lat, const double r, double *x, double *y, double *z)
×
108
{
NEW
109
        const double cosLat = cos(lat);
×
NEW
110
        (*x) = r * cos(lng) * cosLat;
×
NEW
111
        (*y) = r * sin(lng) * cosLat;
×
NEW
112
        (*z) = r * sin(lat);
×
NEW
113
}
×
114

115
/*
116
 Meeus, Astron. Algorithms 2nd ed (1998). Chap 37. Equ 37.1
117
 params : Julian day, Longitude, Latitude, Radius
118

119
 Calculate Pluto heliocentric ecliptical coordinates for given julian day.
120
 This function is accurate to within 0.07" in longitude, 0.02" in latitude
121
 and 0.000006 AU in radius.
122
 Note: This function is not valid outside the period of 1885-2099.
123
 Longitude and Latitude are in radians, radius in AU.
124
*/
NEW
125
void get_pluto_helio_coords (double JDE, double * X, double * Y, double * Z)
×
126
{
127
    /* get julian centuries since J2000 */
NEW
128
    const double t = (JDE - 2451545) / 36525;
×
129

130
    /* calculate mean longitudes for jupiter, saturn and pluto */
NEW
131
    const double J =  34.35 + 3034.9057 * t;
×
NEW
132
    const double S =  50.08 + 1222.1138 * t;
×
NEW
133
    const double P = 238.96 +  144.9600 * t;
×
134

135
    /* calc periodic terms in table 37.A */
136
    //  double sum_longitude = 0, sum_latitude = 0, sum_radius = 0;
137
    //        for (int i=0; i < PLUTO_COEFFS; i++)
138
    //        {
139
    //                const double a = argument[i].J * J + argument[i].S * S + argument[i].P * P;
140
    //                const double sin_a = sin(PI/180.*a);
141
    //                const double cos_a = cos(PI/180.*a);
142
    //
143
    //                /* longitude */
144
    //                sum_longitude += longitude[i].A * sin_a + longitude[i].B * cos_a;
145
    //
146
    //                /* latitude */
147
    //                sum_latitude += latitude[i].A * sin_a + latitude[i].B * cos_a;
148
    //
149
    //                /* radius */
150
    //                sum_radius += radius[i].A * sin_a + radius[i].B * cos_a;
151
    //        }
152
    std::array<double, 3>sum_lon_at_rad =
NEW
153
            std::transform_reduce(STD_EXECUTION_PAR_COMMA
×
154
                                  data.begin(), data.end(), std::array<double, 3>({0.0, 0.0, 0.0}),
NEW
155
                                  [](const std::array<double, 3>&sum, const std::array<double, 3>&addon){
×
NEW
156
        return std::array<double, 3>{sum[0] + addon[0], sum[1] + addon[1], sum[2] + addon[2]};},
×
NEW
157
    [=](const struct pluto_data &d){
×
NEW
158
        const double a = d.J * J + d.S * S + d.P * P;
×
NEW
159
        const double sin_a = sin(M_PI/180.*a);
×
NEW
160
        const double cos_a = cos(M_PI/180.*a);
×
161
        return std::array<double, 3>{
NEW
162
            d.lngA * sin_a + d.lngB * cos_a,
×
NEW
163
                    d.latA * sin_a + d.latB * cos_a,
×
NEW
164
                    d.radA * sin_a + d.radB * cos_a};
×
165
    });
166

167
    /* calc L, B, R */
NEW
168
    const double L = M_PI/180. * (238.958116 + 144.96 * t + sum_lon_at_rad[0] * 0.000001);
×
NEW
169
    const double B = M_PI/180. * (-3.908239 + sum_lon_at_rad[1] * 0.000001);
×
NEW
170
    const double R = (40.7241346 + sum_lon_at_rad[2] * 0.0000001);
×
171

172
    /* convert to rectangular coord */
NEW
173
    sphe_to_rect(L, B, R, X, Y, Z);
×
NEW
174
}
×
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