public static Maneuver CircularizeAtApoapsis(Orbit a,double t) { double aoapsisHeight = Math.Sqrt(((1-a.e)*a.planet.u)/((1+a.e)*a.a)); Vector3D pos; Vector3D vel; a.KepToCartAtTrueAnomaly(out pos,out vel, a.lastTa); pos=-pos; Vector3D dir = new Vector3D(0,0,-1); double apoapsisTa=a.TrueAnomalyAtPosition(pos); double deltaV = a.planet.GetOrbitalVelocity(aoapsisHeight,aoapsisHeight ); MatrixD directions = GetDirections(pos, vel); dir = Vector3D.Transform(dir, directions); return new Maneuver(apoapsisTa,dir,deltaV); }
public static Maneuver GetPlaneMatch(Orbit orbit1, Orbit orbit2,double t) { Vector3D pos1; Vector3D vel1; orbit1.KepToCartAtTrueAnomaly(out pos1, out vel1, t); double dI=orbit1.I-orbit2.I; double deltaV=(2*Math.Sin(dI/2)*Math.Sqrt(1-Math.Pow(orbit1.e,2))*Math.Cos(orbit1.w+t)*orbit1.n*orbit1.a)/(1+orbit1.e*Math.Cos(t)); double V= orbit1.AscendingNodeTrueAnomaly(orbit2); MatrixD directions = GetDirections(pos1, vel1); Vector3D dir = new Vector3D(0, 1, 0); dir = Vector3D.Transform(dir, directions); return new Maneuver(V,dir,deltaV); }
public static Maneuver GetHohmannTransfer(Orbit orbit1,Orbit orbit2,double t) { Vector3D pos1; Vector3D vel1; Vector3D pos2; Vector3D vel2; double now = 0; double deltaV=0; double TransferTime = Math.PI * Math.Sqrt(Math.Pow((orbit1.a + orbit2.a), 3) / (8 * orbit1.planet.u)); double h2 = Math.Sqrt(orbit1.planet.u/Math.Pow(orbit2.a,3)); double angle = Orbit.RadtoDeg(Math.PI - h2 * TransferTime); bool test = true; Vector3D dir = new Vector3D(0,0,-1); //for (int k = 0; k < 6; k++) { if (test == false) { //break; } for (int i = (int)t; i < t + 36000; i++) { orbit1.KepToCartAtTrueAnomaly(out pos1, out vel1, Orbit.DegtoRad(i)); orbit2.KepToCartAtTrueAnomaly(out pos2, out vel2, Orbit.DegtoRad(i)); pos1.Normalize(); pos2.Normalize(); double ang = Orbit.RadtoDeg(orbit1.GetPhaseAngleTrueAnomaly(orbit2, Orbit.DegtoRad(i))); if (ang <= angle + 1 && ang >= angle - 1) { now = i; // if (k >= 4) //{ MatrixD directions = GetDirections(pos1, vel1); dir = Vector3D.Transform(dir, directions); // } orbit1.KepToCartAtTrueAnomaly(out pos1, out vel1, Orbit.DegtoRad(i)); orbit2.KepToCart(out pos2, out vel2, orbit1.TimeOfTrueAnomaly(Orbit.DegtoRad(i)) + TransferTime); double r1 = pos1.Length(); double r2 = pos2.Length(); deltaV = orbit1.planet.GetOrbitalVelocity(r1, (r1 + r2) / 2) - (vel1.Length()); //Math.Sqrt(orbit1.planet.u / r1) * (Math.Sqrt((2 * r2) / (r2 + r1)) - 1); TransferTime = Math.PI * Math.Sqrt(Math.Pow((r1 + r2), 3) / (8 * orbit1.planet.u)); angle = Orbit.RadtoDeg(Math.PI - h2 * TransferTime); test = false; break; } } // } //Console.WriteLine(angle + " Found ang"); Maneuver man = new Maneuver(Orbit.DegtoRad(now), dir, deltaV); return man; }