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


C# Orbit.getAbsolutePositionAtUT方法代码示例

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


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

示例1: projectFreefallEndTime

        //In a landing, we are going to free fall some way and then either hit atmosphere or start
        //decelerating with thrust. Until that happens we can project the orbit forward along a conic section.
        //Given an orbit, this function figures out the time at which the free-fall phase will end
        double projectFreefallEndTime(Orbit offsetOrbit, double startTime)
        {
            Vector3d currentPosition = offsetOrbit.getAbsolutePositionAtUT(startTime);
            double currentAltitude = FlightGlobals.getAltitudeAtPos(currentPosition);

            //check if we are already in the atmosphere or below the deceleration burn end altitude
            if (currentAltitude < part.vessel.mainBody.maxAtmosphereAltitude || currentAltitude < decelerationEndAltitudeASL)
            {
                return vesselState.time;
            }

            Vector3d currentOrbitVelocity = offsetOrbit.getOrbitalVelocityAtUT(startTime);
            Vector3d currentSurfaceVelocity = currentOrbitVelocity - part.vessel.mainBody.getRFrmVel(currentPosition);

            //check if we already should be decelerating or will be momentarily:
            //that is, if our velocity is downward and our speed is close to the nominal deceleration speed
            if (Vector3d.Dot(currentSurfaceVelocity, currentPosition - part.vessel.mainBody.position) < 0
                && currentSurfaceVelocity.magnitude > 0.9 * decelerationSpeed(currentAltitude, vesselState.maxThrustAccel, part.vessel.mainBody))
            {
                return vesselState.time;
            }

            //check if the orbit reenters at all
            double timeToPe = offsetOrbit.timeToPe;
            Vector3d periapsisPosition = offsetOrbit.getAbsolutePositionAtUT(startTime + timeToPe);
            if (FlightGlobals.getAltitudeAtPos(periapsisPosition) > part.vessel.mainBody.maxAtmosphereAltitude)
            {
                return startTime + timeToPe; //return the time of periapsis as a next best number
            }

            //determine time & velocity of reentry
            double minReentryTime = startTime;
            double maxReentryTime = startTime + timeToPe;
            while (maxReentryTime - minReentryTime > 1.0)
            {
                double test = (maxReentryTime + minReentryTime) / 2.0;
                Vector3d testPosition = offsetOrbit.getAbsolutePositionAtUT(test);
                double testAltitude = FlightGlobals.getAltitudeAtPos(testPosition);
                Vector3d testOrbitVelocity = offsetOrbit.getOrbitalVelocityAtUT(test);
                Vector3d testSurfaceVelocity = testOrbitVelocity - part.vessel.mainBody.getRFrmVel(testPosition);
                double testSpeed = testSurfaceVelocity.magnitude;

                if (Vector3d.Dot(testSurfaceVelocity, testPosition - part.vessel.mainBody.position) < 0 &&
                    (testAltitude < part.vessel.mainBody.maxAtmosphereAltitude
                     || testAltitude < decelerationEndAltitudeASL
                     || testSpeed > 0.9 * decelerationSpeed(testAltitude, vesselState.maxThrustAccel, part.vessel.mainBody)))
                {
                    maxReentryTime = test;
                }
                else
                {
                    minReentryTime = test;
                }
            }

            return (maxReentryTime + minReentryTime) / 2;
        }
开发者ID:Majiir,项目名称:MuMechLib,代码行数:60,代码来源:MechJebModuleLandingAutopilot.cs


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