Sign in to follow this  
EK

projected X and projected Y for a given X,Y

Recommended Posts

EK    122
I am trying to figure out a projected x y coordinate on a left hand cartesian coordinate system. Information I have Current Speed = 321 CurrentX = 498472 CurrentY = 439890 Heading = 147 Time = 11718 in ticks represents when I received the current info. Can someone help with a formula to do this?

Share this post


Link to post
Share on other sites
EK    122
I need projectedx and projectedy. So basically from where they are using current x and y, speed and heading and the time since the last update I would like to calculate where they will be when I do my drawing. I need to do this in between updates.

Share this post


Link to post
Share on other sites
sirob    1181
So, you've got a speed and a heading, and you want to know how much the object would move in a certain timeframe?

What are the units here?

Share this post


Link to post
Share on other sites
Nypyren    12061

NewX = CurrentX + (Current Speed * cosf(Heading * PI / 180.0f) * time_elapsed);
NewY = CurrentY + (Current Speed * sinf(Heading * PI / 180.0f) * time_elapsed);


I have no idea if this is what you want, but then again I have no idea what you're talking about.

Any answer is only as good as the question.


"projected" is ambiguous. Programmers will think you mean "vector projection", which you can think of as a line casting a shadow onto some other line or surface. That's what he means by "projected onto what?" YOU mean "projected" = "future estimation"

Are you doing this calculation many times per second, between each frame (like in a game), or are you receiving packets of information kind of like a sonar/radar "ping"?

What is "11718" ticks? Is a tick a second? 1/1000th of a second? Is that the amount of time since you last got an update, or the amount of time since you started keeping track of time?

"Left handed coordinates" means nothing in 2 dimensions... you can point your thumb along +x or -x and still align your index finder to either +y or -y.

Assuming you're using screen-coordinates (X = right, Y = down), increasing an angle will rotate clockwise.

[Edited by - Nypyren on July 1, 2005 9:53:00 PM]

Share this post


Link to post
Share on other sites
EK    122
Yes I mean future estimation and I am receiving packets. The ticks is milliseconds, lastupdate - System.Environment.TickCount so it's the time elapsed since I received the information.


My formula is basically the same as your.

dHyp = iSpeed * (lastupdated) * (1 / 1000)
s = Math.Sin(currentHeading * (180.0 / Math.PI))
c = Math.Cos(currentHeading * (180.0 / Math.PI))
newX = CInt(currentX - Math.Round(s * dHyp))
newY = CInt(currentY + Math.Round(c * dHyp))


Thanks for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this