Fix half orbits due to static limits

This commit is contained in:
tyuXX 2026-11-15 18:17:11 +03:00
parent 5878827d6c
commit 31e72bb439
3 changed files with 19 additions and 12 deletions

View file

@ -133,6 +133,16 @@ export function enterOrbitPhase(ctx: LaunchContext): void {
const curvePts = pts.map( const curvePts = pts.map(
(p) => new THREE.Vector3(p.x * visScale, p.y * visScale, p.z * visScale), (p) => new THREE.Vector3(p.x * visScale, p.y * visScale, p.z * visScale),
); );
const first = curvePts[0];
const last = curvePts[curvePts.length - 1];
const gap = first.distanceTo(last);
const orbitSpan = Math.max(
...curvePts.map((p) => Math.hypot(p.x, p.y, p.z)),
1,
);
if (gap > 1e-3 && gap < orbitSpan * 0.08) {
curvePts.push(first.clone());
}
const lineGeo = new THREE.BufferGeometry().setFromPoints(curvePts); const lineGeo = new THREE.BufferGeometry().setFromPoints(curvePts);
const line = new THREE.Line( const line = new THREE.Line(
lineGeo, lineGeo,

View file

@ -245,7 +245,12 @@ export async function runTrajectory(
: baseDef.sma, : baseDef.sma,
inc: opts.incDeg ?? baseDef.inc, inc: opts.incDeg ?? baseDef.inc,
}; };
const durationSec = def.days * 86400; const orb = orbitForTarget(key, opts);
const durationSec = Math.max(def.days * 86400, orb.period);
const scriptDef =
durationSec > def.days * 86400
? { ...def, days: durationSec / 86400 }
: def;
const analytic = generateTrajectory(key, durationSec, 280, opts); const analytic = generateTrajectory(key, durationSec, 280, opts);
const consoleBin = resolveGmatConsoleBin(); const consoleBin = resolveGmatConsoleBin();
if (!consoleBin) { if (!consoleBin) {
@ -265,20 +270,19 @@ export async function runTrajectory(
fs.unlink(logPath, () => {}); fs.unlink(logPath, () => {});
}; };
try { try {
fs.writeFileSync(scriptPath, buildGmatScript(def)); fs.writeFileSync(scriptPath, buildGmatScript(scriptDef));
const { stdout } = await execFileAsync( const { stdout } = await execFileAsync(
consoleBin, consoleBin,
["-l", logPath, "-r", scriptPath], ["-l", logPath, "-r", scriptPath],
{ {
cwd: gmatDir, cwd: gmatDir,
timeout: 30_000, timeout: 60_000,
maxBuffer: 32 * 1024 * 1024, maxBuffer: 32 * 1024 * 1024,
}, },
); );
cleanup(); cleanup();
const points = parseGmatStdout(stdout); const points = parseGmatStdout(stdout);
if (points.length > 10) { if (points.length > 10) {
const orb = orbitForTarget(key, opts);
const enriched = points.map((p, idx) => { const enriched = points.map((p, idx) => {
const t = (idx / (points.length - 1)) * durationSec; const t = (idx / (points.length - 1)) * durationSec;
const analyticPt = const analyticPt =

View file

@ -492,14 +492,7 @@ export function generateTrajectory(
opts: { altKm?: number; incDeg?: number; ecc?: number } = {}, opts: { altKm?: number; incDeg?: number; ecc?: number } = {},
): TrajectoryResult { ): TrajectoryResult {
const orb = orbitForTarget(target, opts); const orb = orbitForTarget(target, opts);
const totalSec = const totalSec = durationSec ?? orb.period;
durationSec ??
Math.min(
orb.period,
target === "mars" || target === "jupiter" || target === "solar"
? 180 * 86400
: orb.period,
);
const dt = totalSec / numPoints; const dt = totalSec / numPoints;
const points: TrajectoryPoint[] = []; const points: TrajectoryPoint[] = [];
for (let i = 0; i <= numPoints; i++) { for (let i = 0; i <= numPoints; i++) {