Skip to content

Commit 84f3a1e

Browse files
committed
brackets, comment and 1s precision #44
1 parent 3f9d1b1 commit 84f3a1e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Software/Arduino code/Sidereal.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ static const double Sidereal::calculateTheta(double deltaJ, double longitude, fl
1111
double theta = C1;
1212
theta += C2 * deltaJ;
1313
theta += C3 * timeUTC;
14+
theta += C4;
1415
theta += longitude;
1516
return fmod(theta, 360.0);
1617
}
@@ -19,16 +20,17 @@ static const int Sidereal::calculateDeltaJd(int year, int month, int day){
1920
const int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
2021

2122
// Calculating days without leapdays
22-
long int deltaJd = (year - REFERENCE_JEAR) * 365 + day;
23+
long int deltaJd = (year - J2000) * 365 + day;
2324
for (int i=0; i < month - 1; i++){
2425
deltaJd += daysInMonth[i];
2526
}
2627

2728
// Add leapdays
2829
if (month <= 2){
30+
// Not counting current year if we have not passed february yet
2931
year--;
3032
}
31-
deltaJd += (year / 4 - year / 100 + year / 400);
32-
deltaJd -= (REFERENCE_JEAR / 4 - REFERENCE_JEAR / 100 + REFERENCE_JEAR / 400);
33+
deltaJd += year / 4 - year / 100 + year / 400;
34+
deltaJd -= J2000 / 4 - J2000 / 100 + J2000 / 400;
3335
return deltaJd;
3436
}

Software/Arduino code/Sidereal.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
// Constants for sidereal calculation
99
// Source: http://www.stargazing.net/kepler/altaz.html
10-
#define C1 100.46
11-
#define C2 0.985647
12-
#define C3 15.0
13-
#define REFERENCE_JEAR 2000
10+
#define C1 100.46
11+
#define C2 0.985647
12+
#define C3 15.0
13+
#define C4 -0.5125
14+
#define J2000 2000
1415

1516

1617
class Sidereal

0 commit comments

Comments
 (0)