Beispiel #1
0
    protected virtual void UpdateDeterministically()
    {
        if (CurrentGravitySource == null)
        {
            return;
        }

        TimeSinceEpoch += Time.fixedDeltaTime;
        trajectorySolver.UpdateStateVariables(TimeSinceEpoch);
        UpdateStateVectorsBySolver();
    }
Beispiel #2
0
    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);
    }