Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*****************************************************************************************************************/
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export {
SECONDS_IN_DAY,
SECONDS_IN_HOUR,
SECONDS_IN_YEAR,
SPEED_OF_LIGHT
SPEED_OF_LIGHT,
TWO_PI
} from './constants'

/*****************************************************************************************************************/
Expand Down
32 changes: 32 additions & 0 deletions tests/constants.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*****************************************************************************************************************/

// @author Michael Roberts <michael@observerly.com>
// @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)
})
})

/*****************************************************************************************************************/
Loading