public void SetTargetAutomatedLanding(float latitude, float longitude) { var landingError = MechjebAutomatedLanding.GetError(core.vessel.GetName()); var errorVector = new Vector3d(landingError.ErrorX, landingError.ErrorY, landingError.ErrorZ); var worldPos = FlightGlobals.currentMainBody.GetWorldSurfacePosition(latitude, longitude, 0); var correctedWorldPos = worldPos + errorVector; FlightGlobals.currentMainBody.GetLatLonAlt(correctedWorldPos, out var correctedLatitude, out var correctedLongitude, out _); Debug.Log($"SetTargetAutomatedLanding: landing at {correctedLatitude} , {correctedLongitude} "); core.target.SetPositionTarget(mainBody, correctedLatitude, correctedLongitude); }
private void CalculateFinalLandingError() { if (vessel == null) { return; } if (core.LandingLatitude == 0 && core.LandingLongitude == 0) { return; } double expectedLatitude = core.LandingLatitude; double expectedLongitude = core.LandingLongitude; Vector3d expectedLandingPos = FlightGlobals.currentMainBody.GetWorldSurfacePosition(expectedLatitude, expectedLongitude, 0); Vector3d actualLandingPos = core.vessel.GetWorldPos3D(); Vector3d errorVector = expectedLandingPos - actualLandingPos; MechjebAutomatedLanding.AddNewError(core.vessel.GetName(), errorVector); }