Skip to content

Commit

Permalink
LST can be now computed using time or gst
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyro9922 committed Aug 26, 2020
1 parent 950f88b commit c622f38
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
57 changes: 35 additions & 22 deletions include/boost/astronomy/time/time_conversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,49 @@ decimal_hour GST(ptime t)

enum class DIRECTION {WEST, EAST};

decimal_hour compute_LST(double longitude, DIRECTION direction, double gst)
{
//Convert longitude to hours
double long_hours = longitude / 15.0;

switch(direction)
{
case DIRECTION::WEST:
//Multiply with direction
long_hours = -1 * long_hours;
break;
case DIRECTION::EAST:
//Multiply with direction
long_hours = 1 * long_hours;
break;
}

long_hours = long_hours + gst;

//Bring the result into the range 0 to 24 by adding or subtracting 24 if necessary.
//This is the local sidereal time (LST).
long_hours = long_hours - 24.0 * floor(long_hours/24.0);

return {long_hours};
}

//Local Sidereal Time (LST)
decimal_hour LST(double longitude, DIRECTION direction, ptime t)
{
double gst = GST(t).get();

if(longitude == 0)
return {gst};

//Convert longitude to hours
double long_hours = longitude / 15.0;
if(longitude == 0)
return {gst};

switch(direction)
{
case DIRECTION::WEST:
//Multiply with direction
long_hours = -1 * long_hours;
break;
case DIRECTION::EAST:
//Multiply with direction
long_hours = 1 * long_hours;
break;
}

long_hours = long_hours + gst;
return compute_LST(longitude,direction,gst);
}

//Bring the result into the range 0 to 24 by adding or subtracting 24 if necessary.
//This is the local sidereal time (LST).
long_hours = long_hours - 24.0 * floor(long_hours/24.0);
decimal_hour LST(double longitude, DIRECTION direction, double gst)
{
if(longitude == 0)
return {gst};

return {long_hours};
return compute_LST(longitude,direction,gst);
}

#endif //BOOST_ASTRONOMY_TIME_CONVERSIONS
2 changes: 2 additions & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ build-project header ;
build-project coordinate ;
build-project units ;
build-project io ;
build-project time ;

0 comments on commit c622f38

Please sign in to comment.