Fix half orbits due to static limits
This commit is contained in:
parent
5878827d6c
commit
31e72bb439
3 changed files with 19 additions and 12 deletions
|
|
@ -133,6 +133,16 @@ export function enterOrbitPhase(ctx: LaunchContext): void {
|
|||
const curvePts = pts.map(
|
||||
(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 line = new THREE.Line(
|
||||
lineGeo,
|
||||
|
|
|
|||
|
|
@ -245,7 +245,12 @@ export async function runTrajectory(
|
|||
: baseDef.sma,
|
||||
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 consoleBin = resolveGmatConsoleBin();
|
||||
if (!consoleBin) {
|
||||
|
|
@ -265,20 +270,19 @@ export async function runTrajectory(
|
|||
fs.unlink(logPath, () => {});
|
||||
};
|
||||
try {
|
||||
fs.writeFileSync(scriptPath, buildGmatScript(def));
|
||||
fs.writeFileSync(scriptPath, buildGmatScript(scriptDef));
|
||||
const { stdout } = await execFileAsync(
|
||||
consoleBin,
|
||||
["-l", logPath, "-r", scriptPath],
|
||||
{
|
||||
cwd: gmatDir,
|
||||
timeout: 30_000,
|
||||
timeout: 60_000,
|
||||
maxBuffer: 32 * 1024 * 1024,
|
||||
},
|
||||
);
|
||||
cleanup();
|
||||
const points = parseGmatStdout(stdout);
|
||||
if (points.length > 10) {
|
||||
const orb = orbitForTarget(key, opts);
|
||||
const enriched = points.map((p, idx) => {
|
||||
const t = (idx / (points.length - 1)) * durationSec;
|
||||
const analyticPt =
|
||||
|
|
|
|||
|
|
@ -492,14 +492,7 @@ export function generateTrajectory(
|
|||
opts: { altKm?: number; incDeg?: number; ecc?: number } = {},
|
||||
): TrajectoryResult {
|
||||
const orb = orbitForTarget(target, opts);
|
||||
const totalSec =
|
||||
durationSec ??
|
||||
Math.min(
|
||||
orb.period,
|
||||
target === "mars" || target === "jupiter" || target === "solar"
|
||||
? 180 * 86400
|
||||
: orb.period,
|
||||
);
|
||||
const totalSec = durationSec ?? orb.period;
|
||||
const dt = totalSec / numPoints;
|
||||
const points: TrajectoryPoint[] = [];
|
||||
for (let i = 0; i <= numPoints; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue