Starting mean anomalies for steps.

This commit is contained in:
Krafpy
2022-07-16 21:35:31 +02:00
parent a399f72d3b
commit a569721f3c
5 changed files with 41 additions and 6 deletions

View File

@@ -127,6 +127,14 @@ class TrajectoryCalculator {
const { minLegDuration } = this.config;
infos.duration = Math.max(minLegDuration, infos.duration);
}
computeStartingMeanAnomalies() {
for (let i = 1; i < this.steps.length - 1; i++) {
const step = this.steps[i];
const { orbitElts, angles } = step;
const e = orbitElts.eccentricity;
step.startM = Physics3D.meanAnomalyFromTrueAnomaly(angles.begin, e);
}
}
recomputeLegsSecondArcs() {
for (let i = 0; i < this._secondArcsData.length; i++) {
const data = this._secondArcsData[i];
@@ -160,6 +168,7 @@ class TrajectoryCalculator {
drawAngles: { begin: 0, end: TWO_PI },
duration: 0,
dateOfStart: this._lastStepEndDate,
startM: 0,
maneuvre: maneuvre
});
}
@@ -198,7 +207,8 @@ class TrajectoryCalculator {
angles: angles,
drawAngles: drawAngles,
duration: tof,
dateOfStart: this._lastStepEndDate
dateOfStart: this._lastStepEndDate,
startM: 0
});
this._vesselState = periapsisState;
this._secondArcsData.push({
@@ -284,6 +294,7 @@ class TrajectoryCalculator {
drawAngles: drawAngles,
duration: tof,
dateOfStart: this._lastStepEndDate,
startM: 0,
flyby: flybyDetails
});
const exitState = Physics3D.orbitElementsToState(flybyOrbit, body, exitAngle);
@@ -339,6 +350,7 @@ class TrajectoryCalculator {
drawAngles: drawAngles,
duration: arcDuration,
dateOfStart: this._lastStepEndDate,
startM: 0,
maneuvre: maneuvre
});
this._vesselState = encounterState;
@@ -376,6 +388,7 @@ class TrajectoryCalculator {
drawAngles: drawAngles,
duration: arcDuration,
dateOfStart: exitDate,
startM: 0
});
this._vesselState = preDSMState;
this._preDSMState = preDSMState;
@@ -408,7 +421,8 @@ class TrajectoryCalculator {
drawAngles: { begin: 0, end: soiExitAngle },
duration: tof,
dateOfStart: this._lastStepEndDate,
maneuvre: maneuvre
startM: 0,
maneuvre: maneuvre,
});
const exitState = Physics3D.orbitElementsToState(ejOrbit, depBody, soiExitAngle);
this._vesselState = exitState;
@@ -424,7 +438,8 @@ class TrajectoryCalculator {
angles: { begin: 0, end: 0 },
drawAngles: { begin: 0, end: TWO_PI },
duration: 0,
dateOfStart: lerp(dateMin, dateMax, dateParam)
dateOfStart: lerp(dateMin, dateMax, dateParam),
startM: 0
});
}
}

View File

@@ -67,6 +67,7 @@ class TrajectoryOptimizer extends WorkerEnvironment {
this._deltaVs[i] = this._newDeltaVs[i];
}
}
this._bestTrajectory.computeStartingMeanAnomalies();
sendResult({
popChunk: this._evolver.popChunk,
fitChunk: this._evolver.fitChunk,

View File

@@ -194,6 +194,15 @@ class TrajectoryCalculator {
infos.duration = Math.max(minLegDuration, infos.duration);
}
public computeStartingMeanAnomalies(){
for(let i = 1; i < this.steps.length-1; i++){ // ignore begin and end circular orbits
const step = this.steps[i];
const {orbitElts, angles} = step;
const e = orbitElts.eccentricity;
step.startM = Physics3D.meanAnomalyFromTrueAnomaly(angles.begin, e);
}
}
/**
* Recomputes the second arc of a all legs accounting this time for SOI enter points,
* thus providing a more precise visualization of the orbit.
@@ -247,6 +256,7 @@ class TrajectoryCalculator {
drawAngles: {begin: 0, end: TWO_PI},
duration: 0,
dateOfStart: this._lastStepEndDate,
startM: 0,
maneuvre: maneuvre
});
}
@@ -317,7 +327,8 @@ class TrajectoryCalculator {
angles: angles,
drawAngles: drawAngles,
duration: tof,
dateOfStart: this._lastStepEndDate
dateOfStart: this._lastStepEndDate,
startM: 0
});
// Store the state of the vessel at periapsis for further
@@ -457,6 +468,7 @@ class TrajectoryCalculator {
drawAngles: drawAngles,
duration: tof,
dateOfStart: this._lastStepEndDate,
startM: 0,
flyby: flybyDetails
});
@@ -536,6 +548,7 @@ class TrajectoryCalculator {
drawAngles: drawAngles,
duration: arcDuration,
dateOfStart: this._lastStepEndDate,
startM: 0,
maneuvre: maneuvre
});
@@ -598,6 +611,7 @@ class TrajectoryCalculator {
drawAngles: drawAngles,
duration: arcDuration,
dateOfStart: exitDate,
startM: 0
});
// Store the pre-DSM state to use it in the second arc maneuver calculation
@@ -656,7 +670,8 @@ class TrajectoryCalculator {
drawAngles: {begin: 0, end: soiExitAngle},
duration: tof,
dateOfStart: this._lastStepEndDate,
maneuvre: maneuvre
startM: 0,
maneuvre: maneuvre,
});
// Compute the state of the vessel relative to the exited body when exiting its SOI
@@ -679,7 +694,8 @@ class TrajectoryCalculator {
angles: {begin: 0, end: 0},
drawAngles: {begin: 0, end: TWO_PI},
duration: 0,
dateOfStart: lerp(dateMin, dateMax, dateParam)
dateOfStart: lerp(dateMin, dateMax, dateParam),
startM: 0
});
}
}

View File

@@ -110,6 +110,8 @@ class TrajectoryOptimizer extends WorkerEnvironment {
}
}
this._bestTrajectory.computeStartingMeanAnomalies();
sendResult({
popChunk: this._evolver.popChunk,
fitChunk: this._evolver.fitChunk,

1
src/types.d.ts vendored
View File

@@ -215,6 +215,7 @@ type TrajectoryStep = {
drawAngles: ArcEndsAngles,
dateOfStart: number,
duration: number,
startM: number,
maneuvre?: ManeuvreInfo,
flyby?: FlybyInfo
};