Beispiel #1
0
        public LandingPrediction predictLandPosition()
        {
            VesselController.updateBodyPosition();
            var   currentPosition = VesselController.getPosition();
            var   currentVelocity = VesselController.getVelocity();
            float stepsize        = 0.01f;
            float time            = 0.0f;

            while (VesselController.getAltitudeAtPoint(currentPosition) > 0)
            {
                var normalizedVelocity = currentVelocity;
                normalizedVelocity.Normalize();
                currentPosition += currentVelocity * stepsize;
                currentVelocity += -normalizedVelocity * stepsize * (float)VesselController.getDrag()
                                   * (float)calculateDynamicPressure(VesselController.getAltitudeAtPoint(currentPosition), currentVelocity.Length());
                currentVelocity += VesselController.getGravityAtPoint(currentPosition) * stepsize;
                time            += stepsize;
            }
            return(new LandingPrediction()
            {
                Position = currentPosition,
                Velocity = currentVelocity,
                TimeLeft = time
            });
        }