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


C# Orbit.RadiusAtTrueAnomaly方法代码示例

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


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

示例1: DeltaVAndApsisPhaseAngleOfHohmannTransfer

        //Computes the dV of a Hohmann transfer burn at time UT that will put the apoapsis or periapsis
        //of the transfer orbit on top of the target orbit.
        //The output value apsisPhaseAngle is the phase angle between the transferring vessel and the
        //target object as the transferring vessel crosses the target orbit at the apoapsis or periapsis
        //of the transfer orbit.
        //Actually, it's not exactly the phase angle. It's a sort of mean anomaly phase angle. The
        //difference is not important for how this function is used by DeltaVAndTimeForHohmannTransfer.
        private static Vector3d DeltaVAndApsisPhaseAngleOfHohmannTransfer(Orbit o, Orbit target, double UT, out double apsisPhaseAngle)
        {
            Vector3d apsisDirection = -o.SwappedRelativePositionAtUT(UT);
            double desiredApsis = target.RadiusAtTrueAnomaly(MathExtensions.Deg2Rad * target.TrueAnomalyFromVector(apsisDirection));

            Vector3d dV;
            if (desiredApsis > o.ApR)
            {
                dV = DeltaVToChangeApoapsis(o, UT, desiredApsis);
                Orbit transferOrbit = o.PerturbedOrbit(UT, dV);
                double transferApTime = transferOrbit.NextApoapsisTime(UT);
                Vector3d transferApDirection = transferOrbit.SwappedRelativePositionAtApoapsis();  // getRelativePositionAtUT was returning NaNs! :(((((
                double targetTrueAnomaly = target.TrueAnomalyFromVector(transferApDirection);
                double meanAnomalyOffset = 360 * (target.TimeOfTrueAnomaly(targetTrueAnomaly, UT) - transferApTime) / target.period;
                apsisPhaseAngle = meanAnomalyOffset;
            }
            else
            {
                dV = DeltaVToChangePeriapsis(o, UT, desiredApsis);
                Orbit transferOrbit = o.PerturbedOrbit(UT, dV);
                double transferPeTime = transferOrbit.NextPeriapsisTime(UT);
                Vector3d transferPeDirection = transferOrbit.SwappedRelativePositionAtPeriapsis();  // getRelativePositionAtUT was returning NaNs! :(((((
                double targetTrueAnomaly = target.TrueAnomalyFromVector(transferPeDirection);
                double meanAnomalyOffset = 360 * (target.TimeOfTrueAnomaly(targetTrueAnomaly, UT) - transferPeTime) / target.period;
                apsisPhaseAngle = meanAnomalyOffset;
            }

            apsisPhaseAngle = MuUtils.ClampDegrees180(apsisPhaseAngle);

            return dV;
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:38,代码来源:OrbitalManeuverCalculator.cs

示例2: DeltaVAndTimeForHohmannTransfer

        //Computes the time and dV of a Hohmann transfer injection burn such that at apoapsis the transfer
        //orbit passes as close as possible to the target.
        //The output burnUT will be the first transfer window found after the given UT.
        //Assumes o and target are in approximately the same plane, and orbiting in the same direction.
        //Also assumes that o is a perfectly circular orbit (though result should be OK for small eccentricity).
        public static Vector3d DeltaVAndTimeForHohmannTransfer(Orbit o, Orbit target, double UT, out double burnUT)
        {
            double synodicPeriod = o.SynodicPeriod(target);

            Vector3d burnDV = Vector3d.zero;
            burnUT = UT;
            double bestApproachDistance = Double.MaxValue;
            double minTime = UT;
            double maxTime = UT + 1.1 * synodicPeriod;
            int numDivisions = 20;

            for (int iter = 0; iter < 8; iter++)
            {
                double dt = (maxTime - minTime) / numDivisions;
                for (int i = 0; i < numDivisions; i++)
                {
                    double t = minTime + i * dt;
                    Vector3d apsisDirection = -o.SwappedRelativePositionAtUT(t);
                    double desiredApsis = target.RadiusAtTrueAnomaly(target.TrueAnomalyFromVector(apsisDirection));

                    double approachDistance;
                    Vector3d burn;
                    if (desiredApsis > o.ApR)
                    {
                        burn = DeltaVToChangeApoapsis(o, t, desiredApsis);
                        Orbit transferOrbit = o.PerturbedOrbit(t, burn);
                        approachDistance = transferOrbit.Separation(target, transferOrbit.NextApoapsisTime(t));
                    }
                    else
                    {
                        burn = DeltaVToChangePeriapsis(o, t, desiredApsis);
                        Orbit transferOrbit = o.PerturbedOrbit(t, burn);
                        approachDistance = transferOrbit.Separation(target, transferOrbit.NextPeriapsisTime(t));
                    }

                    if (approachDistance < bestApproachDistance)
                    {
                        bestApproachDistance = approachDistance;
                        burnUT = t;
                        burnDV = burn;
                    }
                }
                minTime = MuUtils.Clamp(burnUT - dt, UT, UT + synodicPeriod);
                maxTime = MuUtils.Clamp(burnUT + dt, UT, UT + synodicPeriod);
            }

            return burnDV;
        }
开发者ID:Raf04,项目名称:MechJeb2,代码行数:53,代码来源:OrbitalManeuverCalculator.cs

示例3: PrepData

        // Gather and prepare data needed for rendering this frame.
        protected void PrepData(Orbit orbit, Rectangle rect)
        {
            // Get the color of the body being orbited
            if(!body_colors.TryGetValue(orbit.referenceBody.GetName(), out body_color)){
                body_colors.TryGetValue("Default", out body_color);
            }

            if (rect.Width != 0 && rect.Height != 0)
            {
                width = rect.Width;
                height = rect.Height;
                xoff = rect.X;
                yoff = rect.Y;
            }
            else
            {
                width = dev.width;
                height = dev.height;
                xoff = 0;
                yoff = 0;
            }

            // Orbit info
            ApR = orbit.ApR;
            PeR = orbit.PeR;
            ApA = orbit.ApA;
            PeA = orbit.PeA;

            // Calc the diameter of the reference body and the diameter of its atmosphere
            dia = orbit.referenceBody.Radius * 2;
            atmos_dia = dia + (orbit.referenceBody.maxAtmosphereAltitude * 2);

            semi_major_axis = orbit.semiMajorAxis;
            semi_minor_axis = orbit.semiMinorAxis;
            eccentricity = orbit.eccentricity;

            r = orbit.RadiusAtTrueAnomaly(orbit.trueAnomaly);
            a = orbit.trueAnomaly;//(360.0 - orbit.trueAnomaly) + 90.0;
        }
开发者ID:BGog,项目名称:GHud,代码行数:40,代码来源:OrbitGraph.cs


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