/// <summary> /// Position of the vessel in given time. /// </summary> /// <param name="position">Current position</param> /// <param name="velocity">Current velocity</param> /// <param name="time">Predition time</param> /// <returns>Future position of the vessel.</returns> public static Tuple <double, double, double> FuturePosition(Tuple <double, double, double> position, Tuple <double, double, double> velocity, double time) { for (int t = 0; t < (Int32)time; t++) { position = VectorMath.Add(position, velocity); velocity = NextVelocity(position, velocity); //Check if predicted position if below surface var surfacePos = Radar.SurfacePositionAtPosition(position); if (currentBody.AltitudeAtPosition(position, bodyFrame) < currentBody.AltitudeAtPosition(surfacePos, bodyFrame)) { position = surfacePos; break; //If yes, return surface position instead. } } return(position); }
public static double SrfAltitudeAtPosision(this CelestialBody body, Vector3 position, ReferenceFrame referenceFrame) { return(body.AltitudeAtPosition(position.ToTuple(), referenceFrame) - body.SrfHeightAtPosition(position, referenceFrame)); }