Phase 0: monorepo skeleton (hub, live-map, api, packages, infra, CI)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { solveKepler } from '../src/kepler.js';
|
||||
|
||||
describe('solveKepler', () => {
|
||||
it('returns 0 for M=0, e=0', () => {
|
||||
expect(solveKepler(0, 0)).toBeCloseTo(0, 10);
|
||||
});
|
||||
|
||||
it('returns M for e=0 (circular orbit)', () => {
|
||||
const M = 1.234;
|
||||
expect(solveKepler(M, 0)).toBeCloseTo(M, 10);
|
||||
});
|
||||
|
||||
it('solves low-eccentricity orbits', () => {
|
||||
// E ≈ M + e·sin(M) is the first-order correction
|
||||
const e = 0.1;
|
||||
const M = 0.5;
|
||||
const E = solveKepler(M, e);
|
||||
const residual = E - e * Math.sin(E) - M;
|
||||
expect(residual).toBeCloseTo(0, 10);
|
||||
});
|
||||
|
||||
it('solves high-eccentricity orbits (e=0.9)', () => {
|
||||
const e = 0.9;
|
||||
const M = 1.0;
|
||||
const E = solveKepler(M, e);
|
||||
const residual = E - e * Math.sin(E) - M;
|
||||
expect(residual).toBeCloseTo(0, 10);
|
||||
});
|
||||
|
||||
it('normalizes M to [-π, π]', () => {
|
||||
// 3π and π are equivalent; should give the same E.
|
||||
const e = 0.3;
|
||||
expect(solveKepler(3 * Math.PI, e)).toBeCloseTo(solveKepler(Math.PI, e), 10);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user