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


C# Orbit.DescendingNodeExists方法代码示例

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


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

示例1: MakeNodeImpl

        public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target)
        {
            double UT = timeSelector.ComputeManeuverTime(o, universalTime, target);

            if (!target.NormalTargetExists)
            {
                throw new OperationException("must select a target to match planes with.");
            }
            else if (o.referenceBody != target.TargetOrbit.referenceBody)
            {
                throw new OperationException("can only match planes with an object in the same sphere of influence.");
            }
            else if (timeSelector.timeReference == TimeReference.REL_ASCENDING)
            {
                if (!o.AscendingNodeExists(target.TargetOrbit))
                {
                    throw new OperationException("ascending node with target doesn't exist.");
                }
            }
            else
            {
                if (!o.DescendingNodeExists(target.TargetOrbit))
                {
                    throw new OperationException("descending node with target doesn't exist.");
                }
            }

            Vector3d dV = (timeSelector.timeReference == TimeReference.REL_ASCENDING) ?
                OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesAscending(o, target.TargetOrbit, UT, out UT):
                OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesDescending(o, target.TargetOrbit, UT, out UT);

            return new ManeuverParameters(dV, UT);
        }
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:33,代码来源:OperationPlane.cs

示例2: CheckPreconditions

        bool CheckPreconditions(Orbit o, double UT)
        {
            errorMessage = "";
            bool error = false;

            string burnAltitude = MuUtils.ToSI(o.Radius(UT) - o.referenceBody.Radius) + "m";

            switch (operation)
            {
                case Operation.CIRCULARIZE:
                    break;

                case Operation.ELLIPTICIZE:
                    if (o.referenceBody.Radius + newPeA > o.Radius(UT))
                    {
                        error = true;
                        errorMessage = "new periapsis cannot be higher than the altitude of the burn (" + burnAltitude + ")";
                    }
                    else if (o.referenceBody.Radius + newApA < o.Radius(UT))
                    {
                        error = true;
                        errorMessage = "new apoapsis cannot be lower than the altitude of the burn (" + burnAltitude + ")";
                    }
                    else if (newPeA < -o.referenceBody.Radius)
                    {
                        error = true;
                        errorMessage = "new periapsis cannot be lower than minus the radius of " + o.referenceBody.theName + "(-" + MuUtils.ToSI(o.referenceBody.Radius, 3) + "m)";
                    }
                    break;

                case Operation.PERIAPSIS:
                    if (o.referenceBody.Radius + newPeA > o.Radius(UT))
                    {
                        error = true;
                        errorMessage = "new periapsis cannot be higher than the altitude of the burn (" + burnAltitude + ")";
                    }
                    else if (newPeA < -o.referenceBody.Radius)
                    {
                        error = true;
                        errorMessage = "new periapsis cannot be lower than minus the radius of " + o.referenceBody.theName + "(-" + MuUtils.ToSI(o.referenceBody.Radius, 3) + "m)";
                    }
                    break;

                case Operation.APOAPSIS:
                    if (o.referenceBody.Radius + newApA < o.Radius(UT))
                    {
                        error = true;
                        errorMessage = "new apoapsis cannot be lower than the altitude of the burn (" + burnAltitude + ")";
                    }
                    break;

                case Operation.INCLINATION:
                    break;

                case Operation.PLANE:
                    if (!core.target.NormalTargetExists)
                    {
                        error = true;
                        errorMessage = "must select a target to match planes with.";
                    }
                    else if (o.referenceBody != core.target.Orbit.referenceBody)
                    {
                        error = true;
                        errorMessage = "can only match planes with an object in the same sphere of influence.";
                    }
                    else if (timeReference == TimeReference.REL_ASCENDING)
                    {
                        if (!o.AscendingNodeExists(core.target.Orbit))
                        {
                            error = true;
                            errorMessage = "ascending node with target doesn't exist.";
                        }
                    }
                    else
                    {
                        if (!o.DescendingNodeExists(core.target.Orbit))
                        {
                            error = true;
                            errorMessage = "descending node with target doesn't exist.";
                        }
                    }
                    break;

                case Operation.TRANSFER:
                    if (!core.target.NormalTargetExists)
                    {
                        error = true;
                        errorMessage = "must select a target for the Hohmann transfer.";
                    }
                    else if (o.referenceBody != core.target.Orbit.referenceBody)
                    {
                        error = true;
                        errorMessage = "target for Hohmann transfer must be in the same sphere of influence.";
                    }
                    else if (o.eccentricity > 1)
                    {
                        error = true;
                        errorMessage = "starting orbit for Hohmann transfer must not be hyperbolic.";
                    }
                    else if (core.target.Orbit.eccentricity > 1)
//.........这里部分代码省略.........
开发者ID:ramfreak04,项目名称:MechJeb2,代码行数:101,代码来源:MechJebModuleManeuverPlanner.cs

示例3: MakeNodeImpl

        public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target)
        {
            double UT = timeSelector.ComputeManeuverTime(o, universalTime, target);

            if (!target.NormalTargetExists)
            {
                throw new OperationException("must select a target to match planes with.");
            }
            else if (o.referenceBody != target.TargetOrbit.referenceBody)
            {
                throw new OperationException("can only match planes with an object in the same sphere of influence.");
            }

            var anExists = o.AscendingNodeExists(target.TargetOrbit);
            var dnExists = o.DescendingNodeExists(target.TargetOrbit);
            double anTime = 0;
            double dnTime = 0;
            var anDeltaV = anExists ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesAscending(o, target.TargetOrbit, UT, out anTime) : Vector3d.zero;
            var dnDeltaV = anExists ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesDescending(o, target.TargetOrbit, UT, out dnTime) : Vector3d.zero;
            Vector3d dV;

            if(timeSelector.timeReference == TimeReference.REL_ASCENDING)
            {
                if(!anExists)
                {
                    throw new OperationException("ascending node with target doesn't exist.");
                }
                UT = anTime;
                dV = anDeltaV;
            }
            else if(timeSelector.timeReference == TimeReference.REL_DESCENDING)
            {
                if(!dnExists)
                {
                    throw new OperationException("descending node with target doesn't exist.");
                }
                UT = dnTime;
                dV = dnDeltaV;
            }
            else if(timeSelector.timeReference == TimeReference.REL_NEAREST_AD)
            {
                if(!anExists && !dnExists)
                {
                    throw new OperationException("neither ascending nor descending node with target exists.");
                }
                if(!dnExists || anTime <= dnTime)
                {
                    UT = anTime;
                    dV = anDeltaV;
                }
                else
                {
                    UT = dnTime;
                    dV = dnDeltaV;
                }
            }
            else if(timeSelector.timeReference == TimeReference.REL_HIGHEST_AD)
            {
                if(!anExists && !dnExists)
                {
                    throw new OperationException("neither ascending nor descending node with target exists.");
                }
                if(!dnExists || anDeltaV.magnitude <= dnDeltaV.magnitude)
                {
                    UT = anTime;
                    dV = anDeltaV;
                }
                else
                {
                    UT = dnTime;
                    dV = dnDeltaV;
                }
            }
            else
            {
                throw new OperationException("wrong time reference.");
            }

            return new ManeuverParameters(dV, UT);
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:80,代码来源:OperationPlane.cs


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