当前位置: 首页>>代码示例>>C#>>正文


C# Orbit.Init方法代码示例

本文整理汇总了C#中Orbit.Init方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.Init方法的具体用法?C# Orbit.Init怎么用?C# Orbit.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Orbit的用法示例。


在下文中一共展示了Orbit.Init方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HardsetOrbit

 static void HardsetOrbit(Orbit orbit, Orbit newOrbit)
 {
     orbit.inclination = newOrbit.inclination;
     orbit.eccentricity = newOrbit.eccentricity;
     orbit.semiMajorAxis = newOrbit.semiMajorAxis;
     orbit.LAN = newOrbit.LAN;
     orbit.argumentOfPeriapsis = newOrbit.argumentOfPeriapsis;
     orbit.meanAnomalyAtEpoch = newOrbit.meanAnomalyAtEpoch;
     orbit.epoch = newOrbit.epoch;
     orbit.referenceBody = newOrbit.referenceBody;
     orbit.Init ();
     orbit.UpdateFromUT (Planetarium.GetUniversalTime ());
 }
开发者ID:602p,项目名称:krpc,代码行数:13,代码来源:OrbitTools.cs

示例2: CopyOrbit

 //Credit where credit is due, Thanks hyperedit.
 public static void CopyOrbit(Orbit sourceOrbit, Orbit destinationOrbit)
 {
     destinationOrbit.inclination = sourceOrbit.inclination;
     destinationOrbit.eccentricity = sourceOrbit.eccentricity;
     destinationOrbit.semiMajorAxis = sourceOrbit.semiMajorAxis;
     destinationOrbit.LAN = sourceOrbit.LAN;
     destinationOrbit.argumentOfPeriapsis = sourceOrbit.argumentOfPeriapsis;
     destinationOrbit.meanAnomalyAtEpoch = sourceOrbit.meanAnomalyAtEpoch;
     destinationOrbit.epoch = sourceOrbit.epoch;
     destinationOrbit.referenceBody = sourceOrbit.referenceBody;
     destinationOrbit.Init();
     destinationOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
 }
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:14,代码来源:VesselUtil.cs

示例3: ApplyVesselUpdate

        private void ApplyVesselUpdate(VesselUpdate update)
        {
            if (HighLogic.LoadedScene == GameScenes.LOADING)
            {
                return;
            }
            //Get updating player
            string updatePlayer = LockSystem.fetch.LockExists(update.vesselID) ? LockSystem.fetch.LockOwner(update.vesselID) : "Unknown";
            //Ignore updates to our own vessel if we are in flight and we aren't spectating
            if (!isSpectating && (FlightGlobals.fetch.activeVessel != null ? FlightGlobals.fetch.activeVessel.id.ToString() == update.vesselID : false) && HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                DarkLog.Debug("ApplyVesselUpdate - Ignoring update for active vessel from " + updatePlayer);
                return;
            }
            Vessel updateVessel = FlightGlobals.fetch.vessels.FindLast(v => v.id.ToString() == update.vesselID);
            if (updateVessel == null)
            {
                //DarkLog.Debug("ApplyVesselUpdate - Got vessel update for " + update.vesselID + " but vessel does not exist");
                return;
            }
            CelestialBody updateBody = FlightGlobals.Bodies.Find(b => b.bodyName == update.bodyName);
            if (updateBody == null)
            {
                DarkLog.Debug("ApplyVesselUpdate - updateBody not found");
                return;
            }

            //Rotation
            Quaternion updateRotation = new Quaternion(update.rotation[0], update.rotation[1], update.rotation[2], update.rotation[3]);
            updateVessel.SetRotation(updateVessel.mainBody.bodyTransform.rotation * updateRotation);

            //Position/Velocity
            if (update.isSurfaceUpdate)
            {
                //Get the new position/velocity
                Vector3d updatePostion = updateBody.GetWorldSurfacePosition(update.position[0], update.position[1], update.position[2]);
                Vector3d updateVelocity = updateBody.bodyTransform.rotation * new Vector3d(update.velocity[0], update.velocity[1], update.velocity[2]);
                //Figure out how far away we are if we can
                double updateDistance = Double.PositiveInfinity;
                if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (FlightGlobals.fetch.activeVessel != null))
                {
                    if (FlightGlobals.fetch.activeVessel.mainBody == updateVessel.mainBody)
                    {
                        Vector3d ourPos = FlightGlobals.fetch.activeVessel.mainBody.GetWorldSurfacePosition(FlightGlobals.fetch.activeVessel.latitude, FlightGlobals.fetch.activeVessel.longitude, FlightGlobals.fetch.activeVessel.altitude);
                        Vector3d theirPos = updateVessel.mainBody.GetWorldSurfacePosition(updateVessel.latitude, updateVessel.longitude, updateVessel.altitude);
                        updateDistance = Vector3.Distance(ourPos, theirPos);
                    }
                }
                bool isLoading = (updateDistance < Vessel.loadDistance) && !updateVessel.loaded;
                bool isUnpacking = (updateDistance < updateVessel.distanceUnpackThreshold) && updateVessel.packed && updateVessel.loaded;
                if (updateVessel.HoldPhysics)
                {
                    //DarkLog.Debug("Skipping update, physics held");
                    return;
                }
                //Don't set the position while the vessel is unpacking / loading - It doesn't apply properly.
                if (isUnpacking || isLoading)
                {
                    //DarkLog.Debug("Skipping update, isUnpacking: " + isUnpacking + " isLoading: " + isLoading);
                    return;
                }
                if (updateVessel.packed)
                {
                    updateVessel.latitude = update.position[0];
                    updateVessel.longitude = update.position[1];
                    updateVessel.altitude = update.position[2];
                    if (!updateVessel.LandedOrSplashed)
                    {
                        //Not landed but under 10km.
                        Vector3d orbitalPos = updatePostion - updateBody.position;
                        Vector3d surfaceOrbitVelDiff = updateBody.getRFrmVel(updatePostion);
                        Vector3d orbitalVel = updateVelocity + surfaceOrbitVelDiff;
                        updateVessel.orbitDriver.orbit.UpdateFromStateVectors(orbitalPos.xzy, orbitalVel.xzy, updateBody, Planetarium.GetUniversalTime());
                        updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
                        updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
                        /*
                        DarkLog.Debug("updateVelocity: " + (Vector3)updateVelocity + ", |vel| " + updateVelocity.magnitude);
                        DarkLog.Debug("surfaceOrbitVelDiff: " + (Vector3)surfaceOrbitVelDiff + ", |vel| " + surfaceOrbitVelDiff.magnitude);
                        */
                        /*
                        if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.fetch.activeVessel != null)
                        {
                            DarkLog.Debug("ourVel: " + (Vector3)FlightGlobals.fetch.activeVessel.orbitDriver.vel + ", |vel| " + updateVessel.orbitDriver.vel.magnitude);
                        }
                        DarkLog.Debug("theirVel: " + (Vector3)updateVessel.orbitDriver.vel + ", |vel| " + updateVessel.orbitDriver.vel.magnitude);
                        */
                    }
                }
                else
                {
                    Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
                    updateVessel.SetPosition(updatePostion, true);
                    updateVessel.ChangeWorldVelocity(velocityOffset);
                }
            }
            else
            {
                Orbit updateOrbit = new Orbit(update.orbit[0], update.orbit[1], update.orbit[2], update.orbit[3], update.orbit[4], update.orbit[5], update.orbit[6], updateBody);
                updateOrbit.Init();
                updateOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
//.........这里部分代码省略.........
开发者ID:kevin-ye,项目名称:DarkMultiPlayer,代码行数:101,代码来源:VesselWorker.cs

示例4: Apply


//.........这里部分代码省略.........
                double latitude = updateBody.GetLatitude(updatePostion);
                double longitude = updateBody.GetLongitude(updatePostion);
                double altitude = updateBody.GetAltitude(updatePostion);
                updateVessel.latitude = latitude;
                updateVessel.longitude = longitude;
                updateVessel.altitude = altitude;
                updateVessel.protoVessel.latitude = latitude;
                updateVessel.protoVessel.longitude = longitude;
                updateVessel.protoVessel.altitude = altitude;

                if (updateVessel.packed)
                {
                    if (!updateVessel.LandedOrSplashed)
                    {
                        //Not landed but under 10km.
                        Vector3d orbitalPos = updatePostion - updateBody.position;
                        Vector3d surfaceOrbitVelDiff = updateBody.getRFrmVel(updatePostion);
                        Vector3d orbitalVel = updateVelocity + surfaceOrbitVelDiff;
                        updateVessel.orbitDriver.orbit.UpdateFromStateVectors(orbitalPos.xzy, orbitalVel.xzy, updateBody, Planetarium.GetUniversalTime());
                        updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
                        updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
                    }
                }
                else
                {
                    Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
                    updateVessel.SetPosition(updatePostion, true);
                    updateVessel.ChangeWorldVelocity(velocityOffset);
                }
            }
            else
            {
                Orbit updateOrbit = new Orbit(orbit[0], orbit[1], orbit[2], orbit[3], orbit[4], orbit[5], orbit[6], updateBody);
                updateOrbit.Init();
                updateOrbit.UpdateFromUT(Planetarium.GetUniversalTime());

                double latitude = updateBody.GetLatitude(updateOrbit.pos);
                double longitude = updateBody.GetLongitude(updateOrbit.pos);
                double altitude = updateBody.GetAltitude(updateOrbit.pos);
                updateVessel.latitude = latitude;
                updateVessel.longitude = longitude;
                updateVessel.altitude = altitude;
                updateVessel.protoVessel.latitude = latitude;
                updateVessel.protoVessel.longitude = longitude;
                updateVessel.protoVessel.altitude = altitude;

                if (updateVessel.packed)
                {
                    //The OrbitDriver update call will set the vessel position on the next fixed update
                    VesselUtil.CopyOrbit(updateOrbit, updateVessel.orbitDriver.orbit);
                    updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
                    updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
                }
                else
                {
                    //Vessel.SetPosition is full of fun and games. Avoid at all costs.
                    //Also, It's quite difficult to figure out the world velocity due to Krakensbane, and the reference frame.
                    Vector3d posDelta = updateOrbit.getPositionAtUT(Planetarium.GetUniversalTime()) - updateVessel.orbitDriver.orbit.getPositionAtUT(Planetarium.GetUniversalTime());
                    Vector3d velDelta = updateOrbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy - updateVessel.orbitDriver.orbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy;
                    //Vector3d velDelta = updateOrbit.vel.xzy - updateVessel.orbitDriver.orbit.vel.xzy;
                    updateVessel.Translate(posDelta);
                    updateVessel.ChangeWorldVelocity(velDelta);
                }
            }

            //Rotation
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:67,代码来源:VesselUpdate.cs

示例5: toOrbit

 void toOrbit ()
 {
     const double altitude = 11461728000; /* 10000m/s orbital speed, convenient for verify dV readings */
     CelestialBody body = Planetarium.fetch.Sun;
     Vessel vssl = FlightGlobals.ActiveVessel;
     vssl.Landed = false;
     vssl.Splashed = false;
     vssl.landedAt = String.Empty;
     for (int i = vssl.Parts.Count -1; i >= 0; i--) {
         Part part = vssl.Parts[i];
         if (part.FindModulesImplementing<LaunchClamp> ().Count != 0) {
             part.Die ();
         }
     }
     vssl.GoOnRails();
     var orbit = new Orbit(0, 0, altitude + body.Radius, 0, 0, 0,
                           Planetarium.GetUniversalTime(), body);
     vssl.orbitDriver.orbit = orbit;
     orbit.Init();
 }
开发者ID:ZiwKerman,项目名称:RCSBuildAid,代码行数:20,代码来源:Debug.cs

示例6: CreateRandomOrbitNearby

 public static Orbit CreateRandomOrbitNearby(Orbit baseOrbit)
 {
     Orbit orbit = new Orbit();
     orbit.eccentricity = baseOrbit.eccentricity + (double)UnityEngine.Random.Range(0.0001f, 0.01f);
     orbit.semiMajorAxis = baseOrbit.semiMajorAxis * (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.inclination = baseOrbit.inclination + (double)UnityEngine.Random.Range(-0.001f, 0.001f);
     orbit.LAN = baseOrbit.LAN * (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.argumentOfPeriapsis = baseOrbit.argumentOfPeriapsis * (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.meanAnomalyAtEpoch = baseOrbit.meanAnomalyAtEpoch * (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.epoch = baseOrbit.epoch;
     orbit.referenceBody = baseOrbit.referenceBody;
     orbit.Init();
     return orbit;
 }
开发者ID:Kerbas-ad-astra,项目名称:ThrottleControlledAvionics,代码行数:14,代码来源:OrbitDBG.cs

示例7: CreateRandomOrbitAround

 public static Orbit CreateRandomOrbitAround(CelestialBody body, double minAltitude, double maxAltitude)
 {
     Orbit orbit = new Orbit();
     orbit.referenceBody = body;
     orbit.eccentricity = (double)UnityEngine.Random.Range(0.0001f, 0.01f);
     orbit.semiMajorAxis = (double)UnityEngine.Random.Range((float)minAltitude, (float)maxAltitude);
     orbit.inclination = (double)UnityEngine.Random.Range(-0.001f, 0.001f);
     orbit.LAN = (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.argumentOfPeriapsis = (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.meanAnomalyAtEpoch = (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.epoch = (double)UnityEngine.Random.Range(0.999f, 1.001f);
     orbit.Init();
     return orbit;
 }
开发者ID:Kerbas-ad-astra,项目名称:ThrottleControlledAvionics,代码行数:14,代码来源:OrbitDBG.cs


注:本文中的Orbit.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。