ASW



Loading...
Searching...
No Matches
Moon Class Reference

Calculate the phase of the moon. More...

#include <moon.h>

Public Member Functions

 Moon ()
 
 ~Moon ()
 

Static Public Member Functions

static double phase (int mon, int day, int year)
 
static void nextphase (int &mon, int &day, int &year, int &hr, int &min, int nph)
 
static double flmoon (int n, int nph, long &jd, double &frac)
 
static void Julian2Calendar (long jd, int &mon, int &day, int &year)
 
static long Calendar2Julian (int mon, int day, int year)
 
static bool isDST (long jd)
 
static bool isDST (int mon, int day, int year)
 

Static Private Attributes

static const double RAD = (3.1415926535897/180.0)
 Radians to degree convertion.
 
static const long IGREG = (15+31L*(10+12L*1582))
 
static const double MEAN_LUNAR_CYCLE = 29.53058868
 

Detailed Description

Calculate the phase of the moon.

moon.h

Created March 31, 2004 by Don Dugger

THE SOFTWARE IS PROVIDED ~AS IS~, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

Classes

This class is an all static.

This group of metthods deals with the phases of the moon, it also computes
Julian dates, due to the fact it was needed for the moon calculations. To make it
simpler to work with the Julian calculation there left in rather than creating a
separate class.

Some functions are taken from "Numerical Recipes in C - The Art of Scientific Computing" Second Edition, tranlated with changes for C++ and help clarify the code.
ISBN 0-521-43108-5
(Copyright © Cambridge University Press 1988, 1992)

Lunar Phases

The program definds the phase of the moon as ia floating point number between 0 and 4. The following values apply:

  • 0.0 = New Moon
  • 1.0 = 1st Quarter
  • 2.0 = Full Moon
  • 3.0 = Last Quarter

Definition at line 68 of file moon.h.

Constructor & Destructor Documentation

◆ Moon()

Moon::Moon ( )
inline

Definition at line 79 of file moon.h.

◆ ~Moon()

Moon::~Moon ( )
inline

Definition at line 80 of file moon.h.

Member Function Documentation

◆ Calendar2Julian()

long Moon::Calendar2Julian ( int  mon,
int  day,
int  year 
)
static

Calendar2Julian() computes the date given a julian date

Parameters
monThe month.
dayThe day of the month.
yearThe year.

Definition at line 235 of file moon.c++.

References IGREG.

Referenced by nextphase(), and phase().

◆ flmoon()

double Moon::flmoon ( int  n,
int  nph,
long &  jd,
double &  frac 
)
static

flmoon() calculates the julian date of nth lunar cycle and nph phase of the moon since Jan 1900 n is the number of lunar cycle since Jan 1900 - ??? This is the original function from the book. It's been modified to work in C++. I also rewrote it to be litte clearer. And added comments where I unterstood what was going on and increased the accuracy of a few constants.

Parameters
nThe number of lunar cycles.
nphThe lunar phase.
jdThe Julian date number.
fracThe tractional part of the Julian date number.
Returns
The full Julian date of the nth lunar cycle plus nph phase Note that the integer and fractional parts are returned by references.

Definition at line 162 of file moon.c++.

References RAD.

Referenced by nextphase(), and phase().

◆ isDST() [1/2]

bool Moon::isDST ( int  mon,
int  day,
int  year 
)
static
Parameters
monThe month.
dayThe day of the month.
yearThe year.

Definition at line 269 of file moon.c++.

◆ isDST() [2/2]

bool Moon::isDST ( long  jd)
static

isDST() returns true if the given date is day light savings time There are two versions, one which takes the Julian date and one that takes the monuth, day and year.

Parameters
jdThe Julian date

Definition at line 258 of file moon.c++.

References isDST(), and Julian2Calendar().

Referenced by isDST(), and nextphase().

Here is the call graph for this function:

◆ Julian2Calendar()

void Moon::Julian2Calendar ( long  jd,
int &  mon,
int &  day,
int &  year 
)
static

Julian2Calendar() computes the julian date

Parameters
jdThe Julian date number.
monThe month.
dayThe day of the month.
yearThe year.
Returns
Note that all the return values are references.

Definition at line 205 of file moon.c++.

Referenced by isDST(), and nextphase().

◆ nextphase()

void Moon::nextphase ( int &  mon,
int &  day,
int &  year,
int &  hr,
int &  min,
int  nph 
)
static

nextphase() calculates the date & time of next phase of the moon, that is the next hole number, given the start date.

Parameters
monThe month.
dayThe day of the month.
yearThe year.
hrThe hour.
minThe minute.
nphThe Lunar Phase See above Lunar Phases
Returns
Note that all the return values are references.

Definition at line 120 of file moon.c++.

References Calendar2Julian(), flmoon(), isDST(), and Julian2Calendar().

Here is the call graph for this function:

◆ phase()

double Moon::phase ( int  mon,
int  day,
int  year 
)
static

phase() calculates the phase of the moon at noon of the date given. p> See above Lunar Phases

Parameters
monThe month.
dayThe day of the month.
yearThe year.
Returns
The Lunar Phase see above Lunar Phases

Definition at line 30 of file moon.c++.

References Calendar2Julian(), flmoon(), and MEAN_LUNAR_CYCLE.

Here is the call graph for this function:

Member Data Documentation

◆ IGREG

const long Moon::IGREG = (15+31L*(10+12L*1582))
staticprivate

We will call this the Gregorian Interval. The Gregorian Calendar was adopted in October 15, 1582.

Definition at line 73 of file moon.h.

Referenced by Calendar2Julian().

◆ MEAN_LUNAR_CYCLE

const double Moon::MEAN_LUNAR_CYCLE = 29.53058868
staticprivate

Definition at line 75 of file moon.h.

Referenced by phase().

◆ RAD

const double Moon::RAD = (3.1415926535897/180.0)
staticprivate

Radians to degree convertion.

moon.c++

Created March 31, 2004 by Don Dugger

THE SOFTWARE IS PROVIDED ~AS IS~, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 70 of file moon.h.

Referenced by flmoon().


The documentation for this class was generated from the following files: