Removed unused stuff so typescript will compile
This commit is contained in:
parent
b3366eba01
commit
b7ff286e92
@ -1,6 +1,6 @@
|
|||||||
import type { InterpolationParameters } from "../gui/interpolate";
|
import type { InterpolationParameters } from "../gui/interpolate";
|
||||||
import type { Body } from "./constants";
|
import type { Body } from "./constants";
|
||||||
import { addMatrix, addVector, getVectorMagnitude, invertTwoByTwoMatrix, matrixMultiply, multiplyMatrixWithScalar, normalizeVector, subtractVector, vectorCrossProduct, vectorDotProduct } from "./mathematics";
|
import { addVector, getVectorMagnitude, matrixMultiply, multiplyMatrixWithScalar, normalizeVector, subtractVector, vectorCrossProduct, vectorDotProduct } from "./mathematics";
|
||||||
|
|
||||||
export interface Orbit {
|
export interface Orbit {
|
||||||
semiLatusRectum: number,
|
semiLatusRectum: number,
|
||||||
@ -1425,8 +1425,6 @@ export function findOrbitThroughInterpolation(ownCoordinates: OrbitalCoordinates
|
|||||||
const [firstDistanceAlongDirection, firstDistancePerpendicularToDirection] = getDistances(interpolationParameters.firstOwnAltitude, interpolationParameters.firstTargetAltitude, interpolationParameters.firstDistance);
|
const [firstDistanceAlongDirection, firstDistancePerpendicularToDirection] = getDistances(interpolationParameters.firstOwnAltitude, interpolationParameters.firstTargetAltitude, interpolationParameters.firstDistance);
|
||||||
const [secondDistanceAlongDirection, secondDistancePerpendicularToDirection] = getDistances(interpolationParameters.secondOwnAltitude, interpolationParameters.secondTargetAltitude, interpolationParameters.secondDistance);
|
const [secondDistanceAlongDirection, secondDistancePerpendicularToDirection] = getDistances(interpolationParameters.secondOwnAltitude, interpolationParameters.secondTargetAltitude, interpolationParameters.secondDistance);
|
||||||
|
|
||||||
const phaseAngleDifference = (ownSecondTrueAnomaly + interpolationParameters.secondPhaseAngle) - (ownFirstTrueAnomaly + interpolationParameters.firstPhaseAngle);
|
|
||||||
|
|
||||||
// Now, try some Newton's method to estimate the two position's the target has gone through
|
// Now, try some Newton's method to estimate the two position's the target has gone through
|
||||||
|
|
||||||
// To avoid the maths exploding, we'll scale everything down a bit
|
// To avoid the maths exploding, we'll scale everything down a bit
|
||||||
@ -1464,138 +1462,6 @@ export function findOrbitThroughInterpolation(ownCoordinates: OrbitalCoordinates
|
|||||||
return getVectorMagnitude(addVector(p2, multiplyMatrixWithScalar(-1, p1))) - expectedDistance;
|
return getVectorMagnitude(addVector(p2, multiplyMatrixWithScalar(-1, p1))) - expectedDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
const distancePartialDerivativeAngleOne = (angleOne: number, angleTwo: number) => {
|
|
||||||
let distance = distanceFunction(angleOne, angleTwo) + expectedDistance;
|
|
||||||
return (
|
|
||||||
Math.sin(angleOne) * vectorDotProduct(n11, c2)
|
|
||||||
+ Math.sin(angleOne) * Math.cos(angleTwo) * vectorDotProduct(n21, n11)
|
|
||||||
- Math.sin(angleOne) * Math.cos(angleOne) * vectorDotProduct(n11, n11)
|
|
||||||
- Math.cos(angleOne) * vectorDotProduct(n12, c2)
|
|
||||||
- Math.cos(angleOne) * Math.sin(angleTwo) * vectorDotProduct(n12, n22)
|
|
||||||
+ Math.sin(angleOne) * Math.sin(angleOne) * vectorDotProduct(n12, n12)
|
|
||||||
) / distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
const distancePartialDerivativeAngleTwo = (angleOne: number, angleTwo: number) => {
|
|
||||||
let distance = distanceFunction(angleOne, angleTwo) + expectedDistance;
|
|
||||||
return (
|
|
||||||
Math.cos(angleTwo) * Math.sin(angleTwo) * vectorDotProduct(n22, n22)
|
|
||||||
- Math.cos(angleTwo) * vectorDotProduct(n22, c1)
|
|
||||||
- Math.cos(angleTwo) * Math.sin(angleOne) * vectorDotProduct(n22, n12)
|
|
||||||
- Math.sin(angleTwo) * Math.cos(angleTwo) * vectorDotProduct(n21, n21)
|
|
||||||
+ Math.sin(angleTwo) * vectorDotProduct(n21, c1)
|
|
||||||
+ Math.sin(angleTwo) * Math.cos(angleOne) * vectorDotProduct(n21, n11)
|
|
||||||
) / distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
const planeAngleFunction = (angleOne: number, angleTwo: number) => {
|
|
||||||
const horizontalOne = addVector(
|
|
||||||
c1,
|
|
||||||
multiplyMatrixWithScalar(Math.cos(angleOne), n11)
|
|
||||||
);
|
|
||||||
|
|
||||||
const horizontalTwo = addVector(
|
|
||||||
c2,
|
|
||||||
multiplyMatrixWithScalar(Math.cos(angleTwo), n21)
|
|
||||||
);
|
|
||||||
|
|
||||||
return vectorDotProduct(horizontalOne, horizontalTwo) / (getVectorMagnitude(horizontalOne) * getVectorMagnitude(horizontalTwo)) - Math.cos(phaseAngleDifference);
|
|
||||||
}
|
|
||||||
|
|
||||||
const planeAnglePartialDerivativeAngleOne = (angleOne: number, angleTwo: number) => {
|
|
||||||
const horizontalOne = addVector(
|
|
||||||
c1,
|
|
||||||
multiplyMatrixWithScalar(Math.cos(angleOne), n11)
|
|
||||||
);
|
|
||||||
|
|
||||||
const horizontalTwo = addVector(
|
|
||||||
c2,
|
|
||||||
multiplyMatrixWithScalar(Math.cos(angleTwo), n21)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
-Math.sin(angleOne) * vectorDotProduct(n11, c2)
|
|
||||||
-Math.sin(angleOne) * Math.cos(angleTwo) * vectorDotProduct(n11, n21)
|
|
||||||
-Math.cos(angleOne) * Math.sin(angleOne) * vectorDotProduct(n11, n11) * vectorDotProduct(horizontalOne, horizontalTwo) / getVectorMagnitude(horizontalOne)
|
|
||||||
) / (getVectorMagnitude(horizontalOne) * getVectorMagnitude(horizontalTwo));
|
|
||||||
}
|
|
||||||
|
|
||||||
const planeAnglePartialDerivativeAngleTwo = (angleOne: number, angleTwo: number) => {
|
|
||||||
const horizontalOne = addVector(
|
|
||||||
c1,
|
|
||||||
multiplyMatrixWithScalar(Math.cos(angleOne), n11)
|
|
||||||
);
|
|
||||||
|
|
||||||
const horizontalTwo = addVector(
|
|
||||||
c2,
|
|
||||||
multiplyMatrixWithScalar(Math.cos(angleTwo), n21)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
-Math.sin(angleTwo) * vectorDotProduct(n21, c1)
|
|
||||||
-Math.sin(angleTwo) * Math.cos(angleOne) * vectorDotProduct(n21, n11)
|
|
||||||
-Math.cos(angleTwo) * Math.sin(angleTwo) * vectorDotProduct(n21, n21) * vectorDotProduct(horizontalOne, horizontalTwo) / getVectorMagnitude(horizontalTwo)
|
|
||||||
) / (getVectorMagnitude(horizontalOne) * getVectorMagnitude(horizontalTwo))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to Newton's method up in this bitch
|
|
||||||
const getFunctionVector = (anglesVector: number[][]) => {
|
|
||||||
return [
|
|
||||||
[distanceFunction(anglesVector[0][0], anglesVector[1][0])],
|
|
||||||
[planeAngleFunction(anglesVector[0][0], anglesVector[1][0])]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
const getJacobianMatrix = (anglesVector: number[][]) => {
|
|
||||||
let angleOne = anglesVector[0][0];
|
|
||||||
let angleTwo = anglesVector[1][0];
|
|
||||||
return[
|
|
||||||
[distancePartialDerivativeAngleOne(angleOne, angleTwo), distancePartialDerivativeAngleTwo(angleOne, angleTwo)],
|
|
||||||
[planeAnglePartialDerivativeAngleOne(angleOne, angleTwo), planeAnglePartialDerivativeAngleTwo(angleOne, angleTwo)]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
const performNewtonMethod = (initialGuess: number[][], iterations: number) => {
|
|
||||||
let anglesVector = [
|
|
||||||
[initialGuess[0][0]],
|
|
||||||
[initialGuess[1][0]]
|
|
||||||
];
|
|
||||||
|
|
||||||
for (var i = 0; i < iterations; i++) {
|
|
||||||
let functionVector = getFunctionVector(anglesVector);
|
|
||||||
let jacobianMatrix = getJacobianMatrix(anglesVector);
|
|
||||||
|
|
||||||
let update = matrixMultiply(invertTwoByTwoMatrix(jacobianMatrix), functionVector);
|
|
||||||
|
|
||||||
// Don't make updates too big
|
|
||||||
while (getVectorMagnitude(update) > Math.PI / 100) {
|
|
||||||
update = multiplyMatrixWithScalar(0.5, update);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
// Also don't update if it brings us further away from where we want to be
|
|
||||||
let trialFunctionVector = getFunctionVector(addVector(anglesVector, multiplyMatrixWithScalar(-1, update)));
|
|
||||||
let counter = 0;
|
|
||||||
let deadEnd = false;
|
|
||||||
|
|
||||||
while (Math.abs(trialFunctionVector[0][0]) >= Math.abs(functionVector[0][0])) {
|
|
||||||
counter += 1;
|
|
||||||
if (counter >= 16) {
|
|
||||||
deadEnd = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
update = multiplyMatrixWithScalar(0.5, update);
|
|
||||||
trialFunctionVector = getFunctionVector(addVector(anglesVector, multiplyMatrixWithScalar(-1, update)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deadEnd) {
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
anglesVector = addVector(anglesVector, multiplyMatrixWithScalar(-1, update));
|
|
||||||
};
|
|
||||||
return anglesVector;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getAnglesFromPhaseAngles = (firstPhaseAngle: number, secondPhaseAngle: number) => {
|
const getAnglesFromPhaseAngles = (firstPhaseAngle: number, secondPhaseAngle: number) => {
|
||||||
let angleOne;
|
let angleOne;
|
||||||
let angleTwo;
|
let angleTwo;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { Body } from "../calculations/constants";
|
import type { Body } from "../calculations/constants";
|
||||||
import { extrapolateTrajectory, findCheapestLanding, getOrbitalCoordinates, type OrbitalCoordinates, type ShipParameters } from "../calculations/orbit-calculations";
|
import { extrapolateTrajectory, type OrbitalCoordinates, type ShipParameters } from "../calculations/orbit-calculations";
|
||||||
import type { ChangingStorageValue } from "../storage";
|
import type { ChangingStorageValue } from "../storage";
|
||||||
import { createDisabledInput, createLabel, getCoordinatesFromParameters, getOrbitFromParameters, type OrbitalParameters } from "./common";
|
import { createDisabledInput, createLabel, getCoordinatesFromParameters, type OrbitalParameters } from "./common";
|
||||||
import { type LandingParameters } from "../calculations/orbit-calculations";
|
import { type LandingParameters } from "../calculations/orbit-calculations";
|
||||||
import { LandingParametersGui } from "./landingparameters";
|
import { LandingParametersGui } from "./landingparameters";
|
||||||
import { ShipGui } from "./ship";
|
import { ShipGui } from "./ship";
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { Body } from "../calculations/constants";
|
import type { Body } from "../calculations/constants";
|
||||||
import { findCheapestIntercept, findCheapestLanding, findCheapestTransfer, type Orbit, type OrbitalCoordinates, type ShipParameters, type Transfer } from "../calculations/orbit-calculations";
|
import { findCheapestIntercept, findCheapestLanding, findCheapestTransfer, type Orbit, type OrbitalCoordinates, type ShipParameters, type Transfer } from "../calculations/orbit-calculations";
|
||||||
import type { Landing, LandingParameters, LandingProgressCallbackFunction, Manoeuvre } from "../calculations/orbit-calculations";
|
import type { Landing, LandingParameters, LandingProgressCallbackFunction } from "../calculations/orbit-calculations";
|
||||||
|
|
||||||
const ctx: Worker = self as any;
|
const ctx: Worker = self as any;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user