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


C# Vessel.GetOrbit方法代码示例

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


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

示例1: getVesselState

        public json getVesselState(Vessel vessel)
        {
            Debug.Log ("STEP_XXX_1");
            Orbit orbit = vessel.GetOrbit ();
            //string referenceBody = FlightGlobals.Bodies.IndexOf (orbit.referenceBody).ToString ();
            string referenceBody = orbit.referenceBody.GetName ();

            //List<string> buffer = new List<string>();
            json buffer = new json ();
            buffer.Add ("type", "vessel");

            if (vessel.situation == Vessel.Situations.LANDED) {
                buffer.Add ("state", "landed");
            }
            else if (vessel.situation == Vessel.Situations.SPLASHED) {
                buffer.Add ("state", "splashed");
            }
            else if (vessel.situation == Vessel.Situations.PRELAUNCH) {
                buffer.Add ("state", "prelaunch");
            }
            else if (vessel.situation == Vessel.Situations.FLYING) {
                buffer.Add ("state", "flying");
            }
            else if (vessel.situation == Vessel.Situations.ORBITING) {
                buffer.Add ("state", "orbiting");
            }
            else if (vessel.situation == Vessel.Situations.DOCKED) {
                buffer.Add ("state", "docked");
            }
            else if (vessel.situation == Vessel.Situations.SUB_ORBITAL) {
                buffer.Add ("state", "suborbital");
            }
            else if (vessel.situation == Vessel.Situations.ESCAPING) {
                buffer.Add ("state", "escaping");
            }

            else {
                Debug.Log ("Unknown vessel situation");
                buffer.Add ("state", "unknown");
            } // # 1
            Debug.Log ("STEP_XXX_2");
            buffer.Add ("uid", vessel.id.ToString ());
            buffer.Add ("name", vessel.vesselName); // # 3
            buffer.Add ("ut", Planetarium.GetUniversalTime ()); // # 4
            buffer.Add ("ref", referenceBody); // # 5

            buffer.Add ("lon", vessel.longitude); // # 6
            buffer.Add ("lat", vessel.latitude); // # 7

            buffer.Add ("apo_t", vessel.orbit.timeToAp);
            buffer.Add ("per_t", vessel.orbit.timeToPe);

            // Why was this zero?
            Vector3d r = orbit.getRelativePositionAtUT (Planetarium.GetUniversalTime ());
            Vector3d v = orbit.getOrbitalVelocityAtUT (Planetarium.GetUniversalTime ());

            //Vector3d r = orbit.pos.xzy;
            //Vector3d v = orbit.vel.xzy;
            List<double> RV = new List<double> ();
            Debug.Log ("STEP_XXX_3");
            // TODO explain the coordinate system further
            RV.Add(r.y);
            RV.Add(r.x);
               	RV.Add(r.z);

               	RV.Add(v.y);
               	RV.Add(v.x);
               	RV.Add(v.z);

            buffer.Add ("rv", RV);	// # 8

            Vector3d forward = vessel.ReferenceTransform.forward;
            Vector3d up = vessel.ReferenceTransform.up;
            List<double> fwup = new List<double> ();
            fwup.Add (forward.y);
            fwup.Add (forward.x);
            fwup.Add (forward.z);
            fwup.Add (up.y);
            fwup.Add (up.x);
            fwup.Add (up.z);
            Debug.Log ("STEP_XXX_4");
            buffer.Add ("fwup", fwup);
            //Debug.Log ("SPEED1: " + orbit.getOrbitalVelocityAtUT (Planetarium.GetUniversalTime ()).ToString ()); // Tis is currently used velocity
            //Debug.Log ("SPEED2: " + orbit.GetFrameVelAtUT (Planetarium.GetUniversalTime ()).ToString ());
            //Debug.Log ("SPEED3: " + orbit.GetRelativeVel ().ToString () );
            // GetRelativeVel seems to be OK to get the correct position

            //Debug.Log ("SPEED4: " + orbit.GetRotFrameVel ( ().ToString () );

            //Debug.Log ("POSIT1: " + orbit.getPositionAtUT(Planetarium.GetUniversalTime ()).ToString ());
            //Debug.Log ("POSIT2: " + orbit.getRelativePositionAtUT(Planetarium.GetUniversalTime ()).ToString ()); // Tis is currently used pos
            //Debug.Log ("POSIT3: " + orbit.getTruePositionAtUT (Planetarium.GetUniversalTime ()).ToString ());
            //Debug.Log ("POSIT4: " + orbit.pos.xzy.ToString ());

            //Debug.Log ("FRAMEROT: " + Planetarium.FrameIsRotating ().ToString ());
            //Debug.Log ("FRAMEROT: " + Planetarium.ZupRotation.ToString ());
            //Debug.Log ("FRAMEROT: " + Planetarium.Rotation.ToString ());

            //Debug.Log ("Framerot: " + Planetarium.InverseRotAngle.ToString ());

//.........这里部分代码省略.........
开发者ID:voneiden,项目名称:ksp-missioncontrol,代码行数:101,代码来源:Utilities.cs


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