예제 #1
0
		public static void Forecast(Vector oldP, Vector oldV, Vector dv, out Vector newP, out Vector newV)
		{
			Vector oldA = CalculateA(oldP);
			newP = oldP + oldV + 0.5*(oldA + dv);
			Vector newA = CalculateA(newP);
			newV = oldV + dv + 0.5*(oldA + newA);
		}
예제 #2
0
		public static Vector CalculateA(Vector pos)
		{
			double alen = mu/pos.Len2();
			return alen*pos.Norm();

			//avk
			//var phi = Math.PI + pos.PolarAngle;
			//return new Vector(alen*Math.Cos(phi), alen*Math.Sin(phi));
		}
예제 #3
0
		public static Vector GetStabilizingJump(Vector currentV, Vector currentPos)
		{
			Vector newP;
			Vector newV;
			Forecast(currentPos, currentV, Vector.Zero, out newP, out newV);
			double desirableV = Math.Sqrt(mu / newP.Len());
			var desirableVector = GetTangentVector(newP, desirableV);
			return currentV - desirableVector;
		}
예제 #4
0
		public double[] RunTimeStep(Vector dv)
		{
			dxs.Add(dv.x);
			dys.Add(dv.y);
			Inport[2] = dv.x;
			Inport[3] = dv.y;
			Execute();
			tickCount++;
			return Outport;
		}
예제 #5
0
		public void Can_Forecast()
		{
			Vector p, v;
			var oldP = new Vector(7875.21543323545, -6456995.19753615);
			var oldV = new Vector(37.2566558417302, 7814.84948049812);
			Physics.Forecast(oldP, oldV, Vector.Zero, out p, out v);
			Console.WriteLine(oldP);
			Console.WriteLine(oldV);
			Console.WriteLine(p);
			Console.WriteLine(v);
		}
예제 #6
0
		public double[] RunTimeStep(Vector dv)
		{
			double dx = dv.x;
			double dy = dv.y;
			dxs.Add(dx);
			dys.Add(dy);
			inport[dxPort] = dx;
			inport[dyPort] = dy;
			for (int i = 0; i < imageSize; i++)
				RunInstruction(i);
			tickCount++;
			return outport;
		}
예제 #7
0
		public static Orbit CalculateOrbit(Vector pos, Vector v)
		{
			double alpha = pos.PolarAngle;
			double beta = v.PolarAngle;
			double vAngle = Math.PI/2 - (alpha - beta);
			double vr = v.Len()*Math.Sin(vAngle);
			double vt = v.Len()*Math.Cos(vAngle);
			double H = vt*pos.Len();
			double theta = Math.Atan2(vr, vt - mu/H);
			double orbitAngle = -(theta + alpha - Math.PI);

			double a = (mu*pos.Len())/(2*mu - v.Len2()*pos.Len());
			double e = vr/(mu*Math.Sin(theta)/H);
			double b = a*Math.Sqrt(1 - e*e);
			//SolverLogger.Log("H = " + H);
			return new Orbit {SemiMajorAxis = a, SemiMinorAxis = b, TransformAngle = orbitAngle};
		}
예제 #8
0
		public bool Equals(Vector other)
		{
			return other.x == x && other.y == y;
		}
예제 #9
0
		public Vector Sub(Vector vector)
		{
			return new Vector(x - vector.x, y - vector.y);
		}
예제 #10
0
		public static Vector CalculateHohmannJump(Vector pos, Vector v, double targetR)
		{
			var r = pos.Len();
			var desirableV = Math.Sqrt(2 * mu * targetR / (r * (r + targetR)));
			return v - GetTangentVector(pos, desirableV);
		}
예제 #11
0
		public static Vector GetTangentVector(Vector pos, double v)
		{
			return new Vector(v * pos.y / pos.Len(), -v * pos.x / pos.Len());
		}