private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e) { DebugLogger(e.controllerIndex, "TRIGGER", "pressed", e); ; if (false)//leftController == null) { PorkChopPlot.triggerPork = true; double time = 30d; var thisodata = UXStateManager.GetSource().GetComponent <OrbitData>(); Vector3d r1 = thisodata.getR(); var oe2 = UXStateManager.GetTarget().GetComponent <OrbitData>().GetOE(); var tra2 = OrbitalTools.Program.anomalyAfterTime(OrbitData.parentGM, oe2, time); oe2.tra = tra2; Vector3d r2 = OrbitalTools.Util.oe2rd(OrbitData.parentGM, oe2); Vector3d initVel, finalVel; LambertSolver.Solve(r1, r2, time, OrbitData.parentGM, true, out initVel, out finalVel); thisodata.rv[3] = initVel.x; thisodata.rv[4] = initVel.y; thisodata.rv[5] = initVel.z; } }
public void TestLambertSolver() { (Vector3 re, Vector3 ve) = Earth.GetComponent <VisualizeBodyRealtimeOverview>() .Body.GetGlobalPositionAndVelocityAt(Time.time); (Vector3 rm, Vector3 vm) = Mars.GetComponent <VisualizeBodyRealtimeOverview>() .Body.GetGlobalPositionAndVelocityAt(Time.time + 8); LambertSolver.Solve( Body.GravitationalParameter, re, ve, rm, vm, 8, 0, out Vector3 vi, out Vector3 vf ); Orbit orbit = Orbit.FromPositionAndVelocity(Body, re, vi, Time.time); var body = ScriptableObject.CreateInstance <CelestialBody>(); body.SetOrbit(orbit); GameObject orbitVisual = Instantiate(OrbitPrefab); orbitVisual.GetComponent <VisualizeOrbit>().Body = body; GameObject vesselVisual = Instantiate(VesselPrefab); vesselVisual.GetComponent <VisualizeBodyRealtimeOverview>().Body = body; }