예제 #1
0
        public static double OrbitInterceptTime(string direction, Mission mission)
        {
            var targetInc = mission.Inclination.Value;
            var targetLan = mission.Lan.Value;

            if (direction == "nearest")
            {
                var timeToNorth = OrbitInterceptTime("north", mission);
                var timeToSouth = OrbitInterceptTime("south", mission);

                if (timeToSouth < timeToNorth)
                {
                    mission.Direction = "south";
                    return(timeToSouth);
                }

                mission.Direction = "north";
                return(timeToNorth);
            }

            CurrentNode = NodeVector(targetInc, direction);
            var targetNode = Rodrigues(
                SolarPrimeVector(Connection.Connection.SpaceCenter().ActiveVessel.Orbit.Body.ReferenceFrame),
                new Vector3d(0, 1, 0),
                -targetLan
                );
            var nodeDelta = CurrentNode.AngleTo(targetNode);
            var deltaDir  = new Vector3d().Multiply(targetNode.Cross(CurrentNode));

            if (deltaDir < 0)
            {
                nodeDelta = 360 - nodeDelta;
            }

            return(Connection.Connection.SpaceCenter().ActiveVessel.Orbit.Body.RotationalPeriod *
                   nodeDelta / 360);
        }