# Coordinate change algorithm

• 10-18-2001
Hannwaas
Coordinate change algorithm
Is there any way to calculate how the coordinates of an object changed if it is travelling in a certain diretion?
For instance, say I have a circle moving upwards to the left at an angle of 110 degrees. How can I then calculate how to change its coordinates in the next update of the screen?
• 10-18-2001
SilentStrike
This isn't really an algorithm... its simple vector math ;).

You have a circle moving upwards to the left at an angle of 110 degrees, or you have an object moving in a circle to the left at an angle of 110 degrees?

I'll cover the former.

Basically, you have the velocity vector in magnitude (V) angle (theta, angle from positive x axis, counterclockwise) form... its icky (thats the offical term btw ;) ), because you have to do trig to do anything with it really.

First, convert this vector to components with trig.

Vx (component of velocity in x direction) = V * cos(theta)
Vy (component of velocity in y direction) = V * sin(theta)

Now, the displacement (D, change in position) caused by this unchanging velocity during a given time t is

Dx (displacement in x direction) = Vx * t
Dy (displacement in y direction) = Vy * t

If you have its original position vector P, then the position P' after the time t is simply in vector terms

P' = P + D

Or in scalar terms

P'x = Px + Dx
P'y = Py + Dy
• 10-18-2001
Engineer
This is where trigonometry comes in handy. If you ever took it before, you will know what I am talking about.
• 10-19-2001
Hannwaas
I feared I would have to use trigonometry. I think we'll start with it in school in a couple of week. I haven't taken any trigonometry yet, don't know if the Swedish school system is slowmoving or if I'm just no old enough.
Anyway, thanks a lot, I'll take a look at it.
• 10-19-2001
SilentStrike
I remember being consumed with that problem when I was a freshman in high school. I kept trying to apply the y = mx + b line formula to 2D motion, but it just doesn't work nicely.