Future Position of a Car

This is a discussion on Future Position of a Car within the Game Programming forums, part of the General Programming Boards category; Hi, Hopefully someone can steer me in the right direction (pardon the pun ) I'm trying to code something from ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    29

    Future Position of a Car

    Hi,

    Hopefully someone can steer me in the right direction (pardon the pun )

    I'm trying to code something from a paper to get the future position of a car i.e. p(I, Tc + delta t) the position of car I at current time Tc + delta t. Delta t is only one second.

    The paper is telling me that I need the following:

    v(I,T): motion vector of node I at time T
    p(I,T): position vector of node I at time T
    with relationship:
    p(I,Tc)=p(I,Tr + v(I,Tr)*(Tc-Tr)

    The paper then says that the accuracy of the motion vector is vital and says "Let m denote the motion vector accessed from GPS. Mold and Mnew are the reported motion vectors at the last time and this respectively. Mnew = alpha * Mold + (1-alpha)*m, 0<=alpha<=1 with alpha being 0.3 if the car is in a junction and 0.7 otherwise.

    Basically I'm confused as to information I need exactly to code this. I have the vehicles current (x,y) position, its old (x,y) position one second ago and can therefore calculate its speed. I don't know how I'm supposed to determine its direction or what form that is supposed to take. I also don't understand the distinction between 'm' in comparison with Mnew and Mold.

    Very stuck so any help would be greatly appreciated.
    Thanks in advance.

  2. #2
    msh
    msh is offline
    Novice
    Join Date
    Jul 2009
    Posts
    568
    I'd guess that motion vector is "direction of travel and speed" in plain English.
    Disclaimer: This post shows my ignorance at the time of its making. I claim ownership of but not responsibility for all errors in it. Reference at your own peril.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    29
    Hi Msh,

    Thats what I thought too. Originally I figured I'd calculate the future position by knowing the old position and the speed and assuming it was moving in a straight line (Not sure if this is very accurate). But then I was wondering if there was a better way of incorporating direction?

    Also if they only simply meant for the reader to calculate straight line motion, I don't see what they mean by the equation with the alpha value and the motion vectors?

    Thanks again

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I'm guessing the bit about alpha is that you want to average out the old reading and the new reading (in terms of position) both for numerical accuracy and stability reasons, but if the car had been at a junction you might expect a sudden sharp change of direction (i.e. a turn), hence the shifting of weights to make the newer direction worth "more" than the older direction.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    I have the vehicles current (x,y) position, its old (x,y) position one second ago and can therefore calculate its speed.
    Mold and Mnew are the reported motion vectors
    Your statements are contradictory. If you know the old position and the new position and old vector and the new vector then you can compute the rest by plugging into the formula. If you only knew the old position and new position then you could subtract them and normalize to find the direction vector. However the problem also gives you the direction vectors. Given that information you can plot a bezier curve which approximates the car's path.

    In order to plot the curve you need to interpolate along two line segments over time T. Since vectors are infinite we can create segments from them by using the supplied timeDelta. Essentially if we had motion vector v1 at the old position and we extend it forward into time by 1 second where would it be? You also need to do this for the current motion vector only you need to go back in time by 1 second. Once you have these two vectors you can then pick a sample size and interpolate along v1 and v2 by this coefficient. To find the bezier curve points you create a vector from v1 to v2 and interpolate along it by the same coefficient.

    But to find the next position of the car you simply use the formula you have been given and plug and chug. I do not have enough information to solve this because I have not been told if the acceleration throughout this 1 second was constant or non-constant. If it was non-constant then this problem becomes significantly more complex and you need to use a bit of calculus to solve it.

    with alpha being 0.3 if the car is in a junction and 0.7 otherwise.
    How do you know if the car is in a junction or not? You can determine if this was the case in the previous frame by pluggin in 0.3 and 0.7 into the Mnew formula and comparing the outcome to the vector that was given for the current motion vector. But you have not defined what m is so it will most likely never work without more information.

    p(I,Tc)=p(I,Tr + v(I,Tr)*(Tc-Tr)
    I'm assuming v(I,Tr) here is the Mnew formula or does it represent the given motion vector at time t = 0? Tc - Tr is essentially timeDelta if I'm reading the formula right. It appears the formula is a simple:

    Position += Velocity * timeDelta;

    Or simple crappy Euler integration:

    Accel = F / M
    Velocity += Accel * timeDelta;
    Position += Velocity * timeDelta;

    Tr is the previous time
    Tc is the current time
    v(I,Tr) is the previous motion vector
    p(I,Tc) is the current position
    Tc - Tr is the time delta
    p(I,Tr) is the previous position

    Mnew = alpha * Mold + (1-alpha)*m
    MNew is the new motion vector
    alpha is 0.3 or 0.7
    Mold is the previous motion vector
    1 - alpha is either 0.7 or 0.3
    m is some weight.
    http://local.wasp.uwa.edu.au/~pbourk...interpolation/
    The formula looks like linear interpolation but note that m is an extra variable that is not in any of those interpolation formulas.
    Last edited by VirtualAce; 02-01-2011 at 11:18 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you help me about tolower() in file
    By nctar in forum C Programming
    Replies: 7
    Last Post: 05-12-2010, 10:04 AM
  2. c program help :>
    By n2134 in forum C Programming
    Replies: 9
    Last Post: 02-06-2010, 11:12 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  4. i really need help here
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 04-09-2002, 10:47 PM
  5. I need help with an algorithm
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 04-07-2002, 07:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21