A player is heading at a constant angle θ on an XY plane at a constant velocity v (a signed magnitude, not a vector) by pressing the up arrow. Let his initial position be ( x<sub>0</sub>, y<sub>0</sub> ), then his extrapolated position at time t is
x(t) = x<sub>0</sub> + v * t * cos(θ)
y(t) = y<sub>0</sub> + v * t * sin(θ)
From this, we can see the player's path is moving in a straight line θ radians from the positive X axis.
Now, suppose that in addition to pressing the up arrow to move forwards, the player also presses the right arrow to move rightwards. The player's path will start to curve rightwards. The degree to which the player's path curves is determined by a constant ω radians per second and the amount of time the right arrow key is pressed. For the sake of this question, it is assumed that the right arrow and the up arrow keys are pressed for the same amount of time t. θ is no longer constant, but dependent on ω and time t. The player's heading is now determined by θ(t) = θ<sub>0</sub> + ω * t, where θ<sub>0</sub> is their initial heading.
My challenge is now to extrapolate the position of a player knowing that for every t, θ(t) is changing (but in an entirely predictable fashion).
I know I cannot just substitute θ = θ(t) into the above equations, so I am stuck on how to proceed.
A brute force way to approximate the position would be to divide the interval [0, t] into small time steps and solve the problem for each finite step.
For example...
Define starting point:
x<sub>0</sub> = x<sub>0</sub>
θ<sub>0</sub> = θ<sub>0</sub>
Let,
x<sub>n</sub> = x<sub>n-1</sub> + v * t<sub>n</sub> * cos( θ<sub>n-1</sub> + ω * t<sub>n</sub> )
θ<sub>n</sub> = θ<sub>n-1</sub> + ω * Δt
To approximate x(t) for t = 1, take a small time step Δt = 1/10 and solve x<sub>n</sub> recursively
x<sub>0</sub> = x<sub>0</sub>
x<sub>1</sub> = x<sub>0</sub> + v * (1/10) * cos(θ<sub>0</sub> + ω*(1/10))
x<sub>2</sub> = x<sub>1</sub> + v * (1/10) * cos(θ<sub>1</sub> + ω*(1/10))
x<sub>3</sub> = x<sub>2</sub> + v * (1/10) * cos(θ<sub>2</sub> + ω*(1/10))
x<sub>4</sub> = x<sub>3</sub> + v * (1/10) * cos(θ<sub>3</sub> + ω*(1/10))
x<sub>5</sub> = x<sub>4</sub> + v * (1/10) * cos(θ<sub>4</sub> + ω*(1/10))
x<sub>6</sub> = x<sub>5</sub> + v * (1/10) * cos(θ<sub>5</sub> + ω*(1/10))
x<sub>7</sub> = x<sub>6</sub> + v * (1/10) * cos(θ<sub>6</sub> + ω*(1/10))
x<sub>8</sub> = x<sub>7</sub> + v * (1/10) * cos(θ<sub>7</sub>+ ω*(1/10))
x<sub>9</sub> = x<sub>8</sub> + v * (1/10) * cos(θ<sub>8</sub> + ω*(1/10))
x<sub>10</sub> = x<sub>9</sub> + v * (1/10) * cos(θ<sub>9</sub> + ω*(1/10))
x<sub>10</sub> = x(1) with Δt = 1/10
What I want to do now is make this same calculation as the Lim of Δt -> 0.... the calculus way. How would I go about doing this?
Thanks!
Erik
x(t) = x<sub>0</sub> + v * t * cos(θ)
y(t) = y<sub>0</sub> + v * t * sin(θ)
From this, we can see the player's path is moving in a straight line θ radians from the positive X axis.
Now, suppose that in addition to pressing the up arrow to move forwards, the player also presses the right arrow to move rightwards. The player's path will start to curve rightwards. The degree to which the player's path curves is determined by a constant ω radians per second and the amount of time the right arrow key is pressed. For the sake of this question, it is assumed that the right arrow and the up arrow keys are pressed for the same amount of time t. θ is no longer constant, but dependent on ω and time t. The player's heading is now determined by θ(t) = θ<sub>0</sub> + ω * t, where θ<sub>0</sub> is their initial heading.
My challenge is now to extrapolate the position of a player knowing that for every t, θ(t) is changing (but in an entirely predictable fashion).
I know I cannot just substitute θ = θ(t) into the above equations, so I am stuck on how to proceed.
A brute force way to approximate the position would be to divide the interval [0, t] into small time steps and solve the problem for each finite step.
For example...
Define starting point:
x<sub>0</sub> = x<sub>0</sub>
θ<sub>0</sub> = θ<sub>0</sub>
Let,
x<sub>n</sub> = x<sub>n-1</sub> + v * t<sub>n</sub> * cos( θ<sub>n-1</sub> + ω * t<sub>n</sub> )
θ<sub>n</sub> = θ<sub>n-1</sub> + ω * Δt
To approximate x(t) for t = 1, take a small time step Δt = 1/10 and solve x<sub>n</sub> recursively
x<sub>0</sub> = x<sub>0</sub>
x<sub>1</sub> = x<sub>0</sub> + v * (1/10) * cos(θ<sub>0</sub> + ω*(1/10))
x<sub>2</sub> = x<sub>1</sub> + v * (1/10) * cos(θ<sub>1</sub> + ω*(1/10))
x<sub>3</sub> = x<sub>2</sub> + v * (1/10) * cos(θ<sub>2</sub> + ω*(1/10))
x<sub>4</sub> = x<sub>3</sub> + v * (1/10) * cos(θ<sub>3</sub> + ω*(1/10))
x<sub>5</sub> = x<sub>4</sub> + v * (1/10) * cos(θ<sub>4</sub> + ω*(1/10))
x<sub>6</sub> = x<sub>5</sub> + v * (1/10) * cos(θ<sub>5</sub> + ω*(1/10))
x<sub>7</sub> = x<sub>6</sub> + v * (1/10) * cos(θ<sub>6</sub> + ω*(1/10))
x<sub>8</sub> = x<sub>7</sub> + v * (1/10) * cos(θ<sub>7</sub>+ ω*(1/10))
x<sub>9</sub> = x<sub>8</sub> + v * (1/10) * cos(θ<sub>8</sub> + ω*(1/10))
x<sub>10</sub> = x<sub>9</sub> + v * (1/10) * cos(θ<sub>9</sub> + ω*(1/10))
x<sub>10</sub> = x(1) with Δt = 1/10
What I want to do now is make this same calculation as the Lim of Δt -> 0.... the calculus way. How would I go about doing this?
Thanks!
Erik