From 0b2e97e2354f76e823b33eb53625a992e6fc1400 Mon Sep 17 00:00:00 2001 From: michealroberts Date: Mon, 12 Oct 2026 06:54:01 +0000 Subject: [PATCH] feat: add TWO_PI to constants module in @observerly/astrometry feat: add TWO_PI to constants module in @observerly/astrometry --- src/constants.ts | 10 ++++++++++ src/index.ts | 3 ++- tests/constants.spec.ts | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/constants.spec.ts 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) + }) +}) + +/*****************************************************************************************************************/