Beispiel #1
0
        /// <summary>
        /// In Meters!
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="myMass"></param>
        /// <param name="parentMass"></param>
        /// <param name="sgp_m"></param>
        /// <param name="position_m"></param>
        /// <param name="velocity_m"></param>
        /// <param name="atDateTime"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public static OrbitDB FromVector(Entity parent, double myMass, double parentMass, double sgp_m, Vector3 position_m, Vector3 velocity_m, DateTime atDateTime)
        {
            if (position_m.Length() > OrbitProcessor.GetSOI_AU(parent))
            {
                throw new Exception("Entity not in target SOI");
            }
            //var sgp  = GameConstants.Science.GravitationalConstant * (myMass + parentMass) / 3.347928976e33;
            var ke = OrbitMath.KeplerFromPositionAndVelocity(sgp_m, position_m, velocity_m, atDateTime);


            OrbitDB orbit = new OrbitDB(parent)
            {
                SemiMajorAxis            = ke.SemiMajorAxis,
                Eccentricity             = ke.Eccentricity,
                Inclination              = ke.Inclination,
                LongitudeOfAscendingNode = ke.LoAN,
                ArgumentOfPeriapsis      = ke.AoP,
                MeanAnomalyAtEpoch       = ke.MeanAnomalyAtEpoch,
                Epoch = atDateTime,

                _parentMass = parent.GetDataBlob <MassVolumeDB>().Mass,
                _myMass     = myMass
            };

            orbit.CalculateExtendedParameters();

            var pos = OrbitProcessor.GetAbsolutePosition_m(orbit, atDateTime);

            return(orbit);
        }