protected virtual void CalculateOrbitalParametersFromStateVectors(Vector3 sourceRelativePosition, Vector3 sourceRelativeVelocity) { Trajectory.CalculateOrbitalParametersFromStateVectors(sourceRelativePosition, sourceRelativeVelocity, CurrentGravitySource); // Initialize Solver trajectorySolver.InitializeSolver(sourceRelativePosition, sourceRelativeVelocity, CurrentGravitySource.Mass, Trajectory); // Epoch parameters TimeSinceEpoch = 0f; UpdateStateVectorsBySolver(); // Invoke orbit calculation event, triggering things like trajectory drawing OnOrbitCalculationEvent(); }
public Vector2 PredictPosition(float timeOfFlight) { Vector2 relativePosition = Position; Vector2 relativeVelocity = Velocity; if (CurrentGravitySource != null) { relativePosition -= CurrentGravitySource.Position; relativeVelocity -= CurrentGravitySource.Velocity; } // Initialize Solver UniversalVariableSolver tempTrajSolver = new UniversalVariableSolver(); tempTrajSolver.InitializeSolver(relativePosition, relativeVelocity, CurrentGravitySource.Mass, Trajectory); // Solve for new position given time of flight tempTrajSolver.UpdateStateVariables(timeOfFlight); return(tempTrajSolver.CalculatedPosition.RotateVector(Trajectory.ArgumentOfPeriapsis) + CurrentGravitySource.Position); }
private void UpdateIntersections(float timeToNode, Vector2 relativePosition, Vector2 relativeVelocity) { trajectorySolver.InitializeSolver(relativePosition, relativeVelocity, ship.CurrentGravitySource.Mass, trajectory); intersectionCalculator.PlotNearestSourceIntersections(ship, trajectorySolver.CalculatedPosition, trajectorySolver.CalculatedVelocity, timeToNode, trajectory); }