Skip to content

Commit

Permalink
Merge pull request #49 from observerly/feature/moon/getLunarAnnualEqu…
Browse files Browse the repository at this point in the history
…ationCorrection

feat: Added getLunarAnnualEquationCorrection() to moon module in @observerly/astrometry.
  • Loading branch information
michealroberts authored Aug 21, 2023
2 parents 15db470 + 175a2c5 commit 7ea763d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/moon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@

import { getJulianDate } from './epoch'

import { getSolarMeanAnomaly } from './sun'

import { convertDegreesToRadians as radians } from './utilities'

/*****************************************************************************************************************/

export const getLunarAnnualEquationCorrection = (datetime: Date): number => {
// Correct for the Sun's mean anomaly:
const M = radians(getSolarMeanAnomaly(datetime))

// Get the annual equation correction:
return 0.1858 * Math.sin(M)
}

/*****************************************************************************************************************/

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/moon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { describe, expect, it } from 'vitest'
/*****************************************************************************************************************/

import {
getLunarAnnualEquationCorrection,
getLunarMeanAnomaly,
getLunarMeanGeometricLongitude,
getLunarMeanEclipticLongitude
Expand All @@ -24,6 +25,19 @@ export const datetime = new Date('2021-05-14T00:00:00.000+00:00')

/*****************************************************************************************************************/

describe('getLunarAnnualEquationCorrection', () => {
it('should be defined', () => {
expect(getLunarAnnualEquationCorrection).toBeDefined()
})

it('should return the correct Lunar annual equation correction for the given date', () => {
const Ae = getLunarAnnualEquationCorrection(datetime)
expect(Ae).toBe(0.14508321025194074)
})
})

/*****************************************************************************************************************/

describe('getLunarMeanAnomaly', () => {
it('should be defined', () => {
expect(getLunarMeanAnomaly).toBeDefined()
Expand Down

0 comments on commit 7ea763d

Please sign in to comment.