private void AddError(DMPPosError error) { if (errorCount < errors.Length) { errorCount++; } errors[currentPos] = error; if (currentPos > 1) { updateHz = Math.Round(1 / (errors[currentPos].planetTime - errors[currentPos - 1].planetTime), 1); } distanceError = 0; velocityError = 0; rotationError = 0; for (int avgPos = 0; avgPos < errorCount; avgPos++) { distanceError += errors[avgPos].distance / (double)errorCount; velocityError += errors[avgPos].velocity / (double)errorCount; rotationError += errors[avgPos].rotation / (double)errorCount; } currentPos++; if (currentPos == errors.Length) { currentPos = 0; } }
public void LogError(Guid updateID, double distanceError, double velocityError, double rotationError, double planetTime) { if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && FlightGlobals.fetch != null && FlightGlobals.fetch.activeVessel != null && FlightGlobals.fetch.VesselTarget != null && FlightGlobals.fetch.VesselTarget.GetVessel() != null) { if (FlightGlobals.fetch.VesselTarget.GetVessel().id == updateID && selectedVessel != updateID) { errorCount = 0; currentPos = 0; distanceError = 0; velocityError = 0; rotationError = 0; selectedVessel = updateID; } DMPPosError newError = new DMPPosError(distanceError, velocityError, rotationError, planetTime); AddError(newError); } }