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


C# Orbit.GetEccVector方法代码示例

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


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

示例1: TrueAnomaly

	private static double TrueAnomaly(Orbit orbit, Vector3d direction)
	{
		Vector3d periapsis = orbit.GetEccVector();
        double trueAnomaly = Vector3d.Angle(periapsis, direction) * Deg2Rad;
		if (Vector3d.Dot(Vector3d.Cross(periapsis, direction), orbit.GetOrbitNormal()) < 0) {
			trueAnomaly = TwoPi - trueAnomaly;
		}

		return trueAnomaly;
	}
开发者ID:mercutiodesign,项目名称:TransferWindowPlanner,代码行数:10,代码来源:LambertSolver.cs

示例2: Print_Orbit_info

        /// <summary>
        /// 
        /// </summary>
        /// <param name="o">O.</param>
        private static void Print_Orbit_info(Orbit o)
        {
            if (o == null) {
                Debug.Log("Orbit is null");
                return;
            }
            string Output = "";

            Output +=  "Orbit Info \n";
            Output += "\n activePatch:" + o.activePatch ;
            Output += "\n altitude:"+ o.altitude ;
            //Output += "\n an:"+ o.an ;
            //Output += "\n ApA:"+ o.ApA ;
            //Output += "\n ApR:"+ o.ApR ;
            Output += "\n argumentOfPeriapsis:"+ o.argumentOfPeriapsis ;
            //Output += "\n ClAppr:"+ o.ClAppr ;
            //Output += "\n ClEctr1:"+ o.ClEctr1 ;
            //Output += "\n ClEctr2:"+ o.ClEctr2 ;
            Output += "\n closestEncounterBody:"+ o.closestEncounterBody ;
            Output += "\n closestEncounterLevel:"+ o.closestEncounterLevel ;
            Output += "\n closestEncounterPatch:"+ o.closestEncounterPatch ;
            Output += "\n closestTgtApprUT:"+ o.closestTgtApprUT ;
            //Output += "\n CrAppr:"+ o.CrAppr ;
            //Output += "\n debugAN:"+ o.debugAN ;
            //Output += "\n debugEccVec:"+ o.debugEccVec ;
            //Output += "\n debugH:"+ o.debugH ;
            //Output += "\n debugPos:"+ o.debugPos ;
            //Output += "\n debugVel:"+ o.debugVel ;
            //Output += "\n debug_returnFullEllipseTrajectory:"+ o.debug_returnFullEllipseTrajectory ;
            //Output += "\n E:"+ o.E ;
            //Output += "\n eccentricAnomaly:"+ o.eccentricAnomaly ;
            //Output += "\n eccentricity:"+ o.eccentricity ;
            //Output += "\n eccVec:"+ o.eccVec ;
            //Output += "\n EndUT:"+ o.EndUT ;
            Output += "\n epoch:"+ o.epoch ;
            //Output += "\n FEVp:"+ o.FEVp;
            //Output += "\n FEVs:"+ o.FEVs ;
            //Output += "\n fromE:"+ o.fromE ;
            //Output += "\n fromV:"+ o.fromV ;
            //Output += "\n h:"+ o.h ;
            //Output += "\n inclination:"+ o.inclination ;
            //Output += "\n LAN:"+ o.LAN ;
            //Output += "\n mag:"+ o.mag ;
            //Output += "\n meanAnomaly:"+ o.meanAnomaly ;
            //Output += "\n meanAnomalyAtEpoch:"+ o.meanAnomalyAtEpoch ;
            Output += "\n nearestTT:"+ o.nearestTT ;
            Output += "\n nextPatch:"+ o.nextPatch ;
            Output += "\n nextTT:"+ o.nextTT ;
            //Output += "\n ObT:"+ o.ObT ;
            Output += "\n ObTAtEpoch :"+ o.ObTAtEpoch ;
            //Output += "\n orbitalEnergy :"+ o.orbitalEnergy ;
            //Output += "\n orbitalSpeed:"+ o.orbitalSpeed ;
            //Output += "\n orbitPercent :"+ o.orbitPercent ;
            Output += "\n patchEndTransition :"+ o.patchEndTransition ;
            Output += "\n patchStartTransition :"+ o.patchStartTransition ;
            //Output += "\n period :"+ o.period ;
            //Output += "\n pos :"+ o.pos ;
            Output += "\n previousPatch :"+ o.previousPatch ;
            //Output += "\n radius :"+ o.radius ;
            Output += "\n referenceBody :"+ o.referenceBody ;
            //Output += "\n sampleInterval :"+ o.sampleInterval ;
            Output += "\n secondaryPosAtTransition1 :"+ o.secondaryPosAtTransition1 ;
            Output += "\n secondaryPosAtTransition2 :"+ o.secondaryPosAtTransition2 ;
            //Output += "\n semiLatusRectum :"+ o.semiLatusRectum ;
            //Output += "\n semiMajorAxis :"+ o.semiMajorAxis ;
            //Output += "\n semiMinorAxis :"+ o.semiMinorAxis ;
            //Output += "\n SEVp :"+ o.SEVp ;
            //Output += "\n SEVs :"+ o.SEVs ;
            //Output += "\n StartUT :"+ o.StartUT ;
            Output += "\n timeToAp :"+ o.timeToAp ;
            Output += "\n timeToPe :"+ o.timeToPe ;
            Output += "\n timeToTransition1 :"+ o.timeToTransition1 ;
            Output += "\n timeToTransition2 :"+ o.timeToTransition2 ;
            //Output += "\n toE :"+ o.toE ;
            //Output += "\n toV :"+ o.toV ;
            //Output += "\n trueAnomaly :"+ o.trueAnomaly ;
            //Output += "\n UTappr :"+ o.UTappr ;
            //Output += "\n UTsoi :"+ o.UTsoi ;
            //Output += "\n V :"+ o.V ;
            //Output += "\n vel :"+ o.vel ;

            Debug.Log(Output);

            if (!o.activePatch) {
                return;
            }
            try{

                //Functions
                Output = "Orbit Functions: \n";
                Output += "\n PeA :"+ o.PeA ;
                Output += "\n PeR :"+ o.PeR ;
                Output += "\n GetANVector:"+ o.GetANVector() ;
                Output += "\n GetEccVector:"+ o.GetEccVector() ;
                Output += "\n GetFrameVel:"+ o.GetFrameVel() ;
                Output += "\n GetHashCode:"+ o.GetHashCode() ;
//.........这里部分代码省略.........
开发者ID:ve2dmn,项目名称:AsteroidScanner,代码行数:101,代码来源:MyScanner.cs

示例3: ComputeEjectionManeuver

		static ManeuverParameters ComputeEjectionManeuver(Vector3d exit_velocity, Orbit initial_orbit, double UT_0)
		{
			double GM = initial_orbit.referenceBody.gravParameter;
			double C3 = exit_velocity.sqrMagnitude;
			double sma = -GM / C3;
			double Rpe = initial_orbit.semiMajorAxis;
			double ecc = 1 - Rpe / sma;
			double theta = Math.Acos(-1 / ecc);

			Vector3d intersect_1;
			Vector3d intersect_2;

			// intersect_1 is the optimal position on the orbit assuming the orbit is circular and the sphere of influence is infinite
			IntersectConePlane(exit_velocity, theta, initial_orbit.h, out intersect_1, out intersect_2);

			Vector3d eccvec = initial_orbit.GetEccVector();

			double true_anomaly = AngleAboutAxis(eccvec, intersect_1, initial_orbit.h);
			// GetMeanAnomalyAtTrueAnomaly expects degrees and returns radians
			double mean_anomaly = initial_orbit.GetMeanAnomalyAtTrueAnomaly(true_anomaly * 180 / Math.PI);

			double delta_mean_anomaly = MuUtils.ClampRadiansPi(mean_anomaly - initial_orbit.MeanAnomalyAtUT(UT_0));

			double UT = UT_0 + delta_mean_anomaly / initial_orbit.MeanMotion();

			Vector3d V_0 = initial_orbit.getOrbitalVelocityAtUT(UT);
			Vector3d pos = initial_orbit.getRelativePositionAtUT(UT);

			double final_vel = Math.Sqrt(C3 + 2 * GM / pos.magnitude);

			Vector3d x = pos.normalized;
			Vector3d z = Vector3d.Cross(x, exit_velocity).normalized;
			Vector3d y = Vector3d.Cross(z, x);

			theta = Math.PI / 2;
			double dtheta = 0.001;
			Orbit sample = new Orbit();

			double theta_err = Double.MaxValue;

			for (int iteration = 0 ; iteration < 50 ; ++iteration)
			{
				Vector3d V_1 = final_vel * (Math.Cos(theta) * x + Math.Sin(theta) * y);
				sample.UpdateFromStateVectors(pos, V_1, initial_orbit.referenceBody, UT);
				theta_err = AngleAboutAxis(exit_velocity, sample.getOrbitalVelocityAtUT(OrbitExtensions.NextTimeOfRadius(sample, UT, sample.referenceBody.sphereOfInfluence)), z);
				if (double.IsNaN(theta_err))
					return null;
				if (Math.Abs(theta_err) <= Math.PI / 1800)
					return new ManeuverParameters((V_1 - V_0).xzy, UT);

				V_1 = final_vel * (Math.Cos(theta + dtheta) * x + Math.Sin(theta + dtheta) * y);
				sample.UpdateFromStateVectors(pos, V_1, initial_orbit.referenceBody, UT);
				double theta_err_2 = AngleAboutAxis(exit_velocity, sample.getOrbitalVelocityAtUT(OrbitExtensions.NextTimeOfRadius(sample, UT, sample.referenceBody.sphereOfInfluence)), z);

				V_1 = final_vel * (Math.Cos(theta - dtheta) * x + Math.Sin(theta - dtheta) * y);
				sample.UpdateFromStateVectors(pos, V_1, initial_orbit.referenceBody, UT);
				double theta_err_3 = AngleAboutAxis(exit_velocity, sample.getOrbitalVelocityAtUT(OrbitExtensions.NextTimeOfRadius(sample, UT, sample.referenceBody.sphereOfInfluence)), z);

				double derr = MuUtils.ClampRadiansPi(theta_err_2 - theta_err_3) / (2 * dtheta);

				theta = MuUtils.ClampRadiansTwoPi(theta - theta_err / derr);

				// if theta > pi, replace with 2pi - theta, the function ejection_angle=f(theta) is symmetrc wrt theta=pi
				if (theta > Math.PI)
					theta = 2 * Math.PI - theta;
			}

			return null;
		}
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:69,代码来源:TransferCalculator.cs

示例4: ComputeEjectionManeuver

		public static ManeuverParameters ComputeEjectionManeuver(Vector3d exit_velocity, Orbit initial_orbit, double UT_0)
		{
			double GM = initial_orbit.referenceBody.gravParameter;
			double C3 = exit_velocity.sqrMagnitude;
            double Mh = initial_orbit.referenceBody.sphereOfInfluence;
            double Rpe = initial_orbit.semiMajorAxis;

            double isma = 2 / Mh - C3 / GM; //inverted Semi-major Axis, will work for parabolic orbit
            double ecc = 1.0 - Rpe * isma;

            //double vstart = Math.Sqrt(GM * (2 / Rpe - isma)); //{ total start boost}
            //double slat = Rpe * Rpe * vstart * vstart / GM;

            //the problem here should be R for circular orbit instead of Rpe
            double slat = 2 * Rpe - isma * Rpe * Rpe; //but we don't know start point (yet) in elliptic orbit

            double theta = Math.Acos((slat / Mh - 1) / ecc);


            /*
            //old way infinity hyperbolic:
            //problems: it's not necessary hyperbolic (in case of low speed exit_velocity), 
            //and exit_velocity appears not infinite far from celestial body, but only sphereOfInfluence far
            //i.e. Mh in previous statements(theta, isma) is not infinity!

			double sma = -GM / C3;
			
			double ecc = 1 - Rpe / sma;
			double theta = Math.Acos(-1 / ecc);

            */
            Vector3d intersect_1;
			Vector3d intersect_2;

			// intersect_1 is the optimal position on the orbit assuming the orbit is circular and the sphere of influence is infinite
			IntersectConePlane(exit_velocity, theta, initial_orbit.h, out intersect_1, out intersect_2);

			Vector3d eccvec = initial_orbit.GetEccVector();

			double true_anomaly = AngleAboutAxis(eccvec, intersect_1, initial_orbit.h);
			// GetMeanAnomalyAtTrueAnomaly expects degrees and returns radians
			double mean_anomaly = initial_orbit.GetMeanAnomalyAtTrueAnomaly(true_anomaly * 180 / Math.PI);

			double delta_mean_anomaly = MuUtils.ClampRadiansPi(mean_anomaly - initial_orbit.MeanAnomalyAtUT(UT_0));

			double UT = UT_0 + delta_mean_anomaly / initial_orbit.MeanMotion();

			Vector3d V_0 = initial_orbit.getOrbitalVelocityAtUT(UT);
			Vector3d pos = initial_orbit.getRelativePositionAtUT(UT);

			double final_vel = Math.Sqrt(C3 + 2 * GM / pos.magnitude);

			Vector3d x = pos.normalized;
			Vector3d z = Vector3d.Cross(x, exit_velocity).normalized;
			Vector3d y = Vector3d.Cross(z, x);

			theta = Math.PI / 2;
			double dtheta = 0.001;
			Orbit sample = new Orbit();

			double theta_err = Double.MaxValue;

			for (int iteration = 0 ; iteration < 50 ; ++iteration)
			{
				Vector3d V_1 = final_vel * (Math.Cos(theta) * x + Math.Sin(theta) * y);
				sample.UpdateFromStateVectors(pos, V_1, initial_orbit.referenceBody, UT);
				theta_err = AngleAboutAxis(exit_velocity, sample.getOrbitalVelocityAtUT(OrbitExtensions.NextTimeOfRadius(sample, UT, sample.referenceBody.sphereOfInfluence)), z);
				if (double.IsNaN(theta_err))
					return null;
				if (Math.Abs(theta_err) <= Math.PI / 1800)
					return new ManeuverParameters((V_1 - V_0).xzy, UT);

				V_1 = final_vel * (Math.Cos(theta + dtheta) * x + Math.Sin(theta + dtheta) * y);
				sample.UpdateFromStateVectors(pos, V_1, initial_orbit.referenceBody, UT);
				double theta_err_2 = AngleAboutAxis(exit_velocity, sample.getOrbitalVelocityAtUT(OrbitExtensions.NextTimeOfRadius(sample, UT, sample.referenceBody.sphereOfInfluence)), z);

				V_1 = final_vel * (Math.Cos(theta - dtheta) * x + Math.Sin(theta - dtheta) * y);
				sample.UpdateFromStateVectors(pos, V_1, initial_orbit.referenceBody, UT);
				double theta_err_3 = AngleAboutAxis(exit_velocity, sample.getOrbitalVelocityAtUT(OrbitExtensions.NextTimeOfRadius(sample, UT, sample.referenceBody.sphereOfInfluence)), z);

				double derr = MuUtils.ClampRadiansPi(theta_err_2 - theta_err_3) / (2 * dtheta);

				theta = MuUtils.ClampRadiansTwoPi(theta - theta_err / derr);

				// if theta > pi, replace with 2pi - theta, the function ejection_angle=f(theta) is symmetrc wrt theta=pi
				if (theta > Math.PI)
					theta = 2 * Math.PI - theta;
			}

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


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