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); }
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)); }
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; }
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; }
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); }
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; }
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}; }
public bool Equals(Vector other) { return other.x == x && other.y == y; }
public Vector Sub(Vector vector) { return new Vector(x - vector.x, y - vector.y); }
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); }
public static Vector GetTangentVector(Vector pos, double v) { return new Vector(v * pos.y / pos.Len(), -v * pos.x / pos.Len()); }