• Forum
  • Lounge
  • Get best flight length when know 2 count

 
Get best flight length when know 2 countries' coordinates

N is north , S south, E east, W west.

A country might have 4 kinds of coordinates : {N,E},{N,W},{S,E},{S,W}

There are some questions around this :

1. I can find distance between 2 points in x,y axis... but I couldn't calculate for different like {N,E} and {N,W}.

2. Convert from one kind to another ?

3. Find the best route : shortest length ?

Please help, thanks in advance.
Here are two commonly used algorithms to find the shortest path between two nodes:
- Dijkstra's algorithm: http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
- A* search algorithm: http://en.wikipedia.org/wiki/A*_search_algorithm / http://www.policyalmanac.org/games/aStarTutorial.htm
Last edited on
The shortest path between two points is the 'straight' line.
As you deform a rectangle into a spherical cap, the straight line is now a great circle http://en.wikipedia.org/wiki/Great-circle_distance

Edit:
For the correspondence between x,y and \theta, \lambda, it depends on the projection
http://xkcd.com/977/
Last edited on
@ne555,
You're right, I'm way overthinking this - OP doesn't need to use a path-finding algorithm.

To get the magnitude of a straight line AB you just need to calculate |AB|= sqrt((x2 - x1)2 + (y2 - y1)2. where "sqrt" is the square root.

(These forums could benefit from having jsMath).
Last edited on
Topic archived. No new replies allowed.