[Corrected] Extrapolating Position on an XY Plane

e2dot718

New member
Joined
Jul 20, 2006
Messages
7
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
 
e2dot718 said:
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.

Write the velocity as a vector:

\(\displaystyle \large
\bf{v}(t) = \left[{v\ \cos(\theta_0+\omega\ t) \atop v\ \sin(\theta_0+\omega\ t)}\right]\)

Now integrate to get position:

\(\displaystyle \large
\bf{x}(t)=\bf{x}(0)\ +\int_0^t \bf{v}(\xi)\ d\xi \\
\ \ =

\left[{x(0)+(v/\omega)\ [\sin(\theta_0+\omega\ t)-\sin(\theta)] \atop
y(0)-(v/\omega)\ [\cos(\theta_0+\omega\ t)-\cos(\theta)]}\right]\)

RonL
 
Ron,

You're are a godsend. I was trying to visualize the problem, which is how I got the sequence. But I couldn't visualize integrating it since I kept thinking that I'd end up with the equation for the area under the curve. But now I realize that when it's thought of as a vector broken down in to the x and y components that the integral is really just summing up the segments on each axis independently.

Erik
 
Top