diff --git a/dist/dedicated-workers/libs/trajectory-calculator.js b/dist/dedicated-workers/libs/trajectory-calculator.js index 3786a6c..e0ecb34 100644 --- a/dist/dedicated-workers/libs/trajectory-calculator.js +++ b/dist/dedicated-workers/libs/trajectory-calculator.js @@ -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 }); } } diff --git a/dist/dedicated-workers/trajectory-optimizer.js b/dist/dedicated-workers/trajectory-optimizer.js index b37a38d..49608ac 100644 --- a/dist/dedicated-workers/trajectory-optimizer.js +++ b/dist/dedicated-workers/trajectory-optimizer.js @@ -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, diff --git a/src/dedicated-workers/libs/trajectory-calculator.ts b/src/dedicated-workers/libs/trajectory-calculator.ts index e8cba34..d679961 100644 --- a/src/dedicated-workers/libs/trajectory-calculator.ts +++ b/src/dedicated-workers/libs/trajectory-calculator.ts @@ -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 }); } } \ No newline at end of file diff --git a/src/dedicated-workers/trajectory-optimizer.ts b/src/dedicated-workers/trajectory-optimizer.ts index cfdc857..37447dc 100644 --- a/src/dedicated-workers/trajectory-optimizer.ts +++ b/src/dedicated-workers/trajectory-optimizer.ts @@ -110,6 +110,8 @@ class TrajectoryOptimizer extends WorkerEnvironment { } } + this._bestTrajectory.computeStartingMeanAnomalies(); + sendResult({ popChunk: this._evolver.popChunk, fitChunk: this._evolver.fitChunk, diff --git a/src/types.d.ts b/src/types.d.ts index a7d85b0..fff2596 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -215,6 +215,7 @@ type TrajectoryStep = { drawAngles: ArcEndsAngles, dateOfStart: number, duration: number, + startM: number, maneuvre?: ManeuvreInfo, flyby?: FlybyInfo };