diff --git a/src/constants.ts b/src/constants.ts index 813f949..af48928 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -106,3 +106,13 @@ export const J1970 = 2440587.5 as const export const J2000 = 2451545.0 as const /*****************************************************************************************************************/ + +/** + * + * Two pi, e.g., the angle of a whole turn (in radians), or the circumference of a circle of a + * unit radius. + * + */ +export const TWO_PI = 2 * Math.PI + +/*****************************************************************************************************************/ diff --git a/src/index.ts b/src/index.ts index 26bc608..56b8a22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -90,7 +90,8 @@ export { SECONDS_IN_DAY, SECONDS_IN_HOUR, SECONDS_IN_YEAR, - SPEED_OF_LIGHT + SPEED_OF_LIGHT, + TWO_PI } from './constants' /*****************************************************************************************************************/ diff --git a/tests/constants.spec.ts b/tests/constants.spec.ts new file mode 100644 index 0000000..f01ee8d --- /dev/null +++ b/tests/constants.spec.ts @@ -0,0 +1,32 @@ +/*****************************************************************************************************************/ + +// @author Michael Roberts +// @package @observerly/astrometry/constants +// @license Copyright © 2021-2026 observerly + +/*****************************************************************************************************************/ + +import { describe, expect, it } from 'vitest' + +/*****************************************************************************************************************/ + +import { TWO_PI } from '../src/constants' + +/*****************************************************************************************************************/ + +describe('TWO_PI', () => { + it('should be defined', () => { + expect(TWO_PI).toBeDefined() + }) + + it('should be two pi, e.g., the angle of a whole turn (in radians)', () => { + expect(TWO_PI).toBe(2 * Math.PI) + expect(TWO_PI).toBeCloseTo(6.283185307179586, 15) + }) + + it('should be the angle of a whole turn of 360°', () => { + expect((TWO_PI * 180) / Math.PI).toBe(360) + }) +}) + +/*****************************************************************************************************************/