Results 1 to 5 of 5

Thread: Algorithm for calculating shortest distance within a time frame

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    3

    Algorithm for calculating shortest distance within a time frame

    Hi

    I am trying to solve a real tough problem ANY HELP WILL BE REALLY APPRECIATED.

    I am trying to simulate planes flying within a sector, i need to check whether they have a specified horizontal seperation (if at same altitude) or vertical seperation. I need a algorithm which will help me calculate shortest distance between two lines within a time interval., i have starting x1,y1 coordinate and ending x2,y2 coordinate, the user will enter the altitude, speed and time entered and exited from the sector.

    Please help

    thanks

    nimesh

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Re: Algorithm for calculating shortest distance within a time frame

    the distance between them will be

    sqrt( (x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2)

    Does that help at all?

    Other wise you can use vectors and the dot product to find the shortest distance

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    3

    Re: Algorithm for calculating shortest distance within a time frame

    Hi

    I was thinking of incorporating vectors and dot product but how do i incoporate the fact that i have a two dimensional line as the third dimension which is alitude will remain the same, also since they are moving how do i implement that fact.

    thanks

    nimesh

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Re: Algorithm for calculating shortest distance within a time frame

    if their altitude is the same, then you don't need to worry about z (or k)

    so for the first plane, say it's moving north at 5m/s (lol, so slow),

    its vector would be

    a = x1i + (y1+5t)j

    and plane b is heading east at 10m/s

    so its vector would be
    b = (x2+10t)i + y2j

    then you'd find the time when the two vectors are perpendicular to each other

    a.b = x1(x2+10t) + y2(y1+5t) = 0

    solve for t, substitute the value of t into the 2 vectors, then find the distance between the two

    or i guess you could find |a-b|

    which would be like

    sqrt((x1-(x2+10t))^2 + ((y1+5t)-y2)^2)

    i think...

    play around a little

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    3

    Re: Algorithm for calculating shortest distance within a time frame

    Hi

    Ya that could work out, i am right on it now. I really appreciate your help.

    thanks

    Nimesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width