# Direction of Line (I think)

• February 9th 2011, 03:38 AM
kerrymaid
Direction of Line (I think)
Hi,

I'm not sure if this falls under the category of coordinate geometry or trigonometry. I need to determine the direction an object is moving in order to figure out its future position, Pf. This works for me when the object is moving to the right but I don’t know how to change the formula when it’s moving left (and how to identify when to change the formula). I assume a 2D cartesian space.

So currently this is what I know. An object was at position (1,3) at t=6 and (3,3) at t=7. I need to figure out where the object will be at t=8.

From what I know I can work out the speed is 2m/s (using the distance formula and speed = distance * time).

Angle = inverse tan ((y2-y1)/(x2-x1)) = 0

Vx = speed * cos(Angle) = 2 * cos (0) = 2
Vy = speed * sin(Angle) = 2 * sin (0) = 0

Future X Position Pfx = Vx + Current X Position = 2 + 3 = 5
Future Y Position Pfy = Vy + Current Y Position = 0 + 3 = 3

Pf = (5,3)

All the above is ok. The problem is if I reverse this example and have an object at position (5,3) at t=6 and (3,3) at t=7, clearly I should get an answer of (1,3) at t=8 but according to the above calculations I don’t. Therefore I need some way of incorporating a direction.

Any help appreciated.
• February 9th 2011, 04:48 AM
skeeter
position (5,3) at t = 6
position (3,3) at t = 7

familiar w/ parametric equations? (x,y) as a function of time ...

x = 17 - 2t

y = 3
• February 9th 2011, 05:09 AM
emakarov
Quote:

Angle = inverse tan ((y2-y1)/(x2-x1)) = 0
The problem is that tangent is not a one-to-one mapping: $\tan(0)=\tan(180)$. In the second example, the angle should be $180^\circ$ since you are moving left. However, (y2 - y1) / (x2 - x1) is still 0 since y2 = y1, just as when you are moving right. Since $\tan^{-1}$ is a function, it must return a single value for the argument 0, and it returns 0, not $180^\circ$.

If you don't need the angle elsewhere, then it is easier to consider x and y coordinates separately. Suppose you have two moments t0 and t1. Then x(t) = x(t0) + (t - t0) * (x(t1) - x(t0)) / (t1 - t0), and similarly for y(t).
• February 9th 2011, 05:15 AM
HallsofIvy
Quote:

Originally Posted by kerrymaid
Hi,

I'm not sure if this falls under the category of coordinate geometry or trigonometry. I need to determine the direction an object is moving in order to figure out its future position, Pf. This works for me when the object is moving to the right but I don’t know how to change the formula when it’s moving left (and how to identify when to change the formula). I assume a 2D cartesian space.

So currently this is what I know. An object was at position (1,3) at t=6 and (3,3) at t=7. I need to figure out where the object will be at t=8.

From (1, 3) to (3, 3) is a vector of <3- 1, 3- 3>= <2, 0>. Adding that again to (3, 3), we get (3+ 2, 3+ 0)= (5, 3).

Quote:

From what I know I can work out the speed is 2m/s (using the distance formula and speed = distance * time).

Angle = inverse tan ((y2-y1)/(x2-x1)) = 0

Vx = speed * cos(Angle) = 2 * cos (0) = 2
Vy = speed * sin(Angle) = 2 * sin (0) = 0

Future X Position Pfx = Vx + Current X Position = 2 + 3 = 5
Future Y Position Pfy = Vy + Current Y Position = 0 + 3 = 3

Pf = (5,3)

All the above is ok. The problem is if I reverse this example and have an object at position (5,3) at t=6 and (3,3) at t=7, clearly I should get an answer of (1,3) at t=8 but according to the above calculations I don’t. Therefore I need some way of incorporating a direction.

Any help appreciated.
From (5,3) to (3, 3) is <3- 5, 3- 3>= <-2, 0>. Adding that again to (3, 3) gives (3-2, 3+ 0)= (1, 3).