sudar
sudar

Reputation: 19

Lat – Long Converter ,Angle and Distance Calculator

Lat – Long Converter ,Angle and Distance Calculator

This algorithm is used to convert the given latitude and longitude positions to XY co-ordinate system. This algorithm also finds the angle and distance between the any 2 positions and the angle between them. The distance matrix is formed by finding the distance of each customer from every other customer and is passed on to the nearest neighbor algorithm.

Pseudo Code

  1. Convert all the given co-ordinate positions into radians.
  2. Set r as the square root value of the sum of lat ,long values.
  3. Set the angle as the radian value of the rotation angle.
  4. If r is greater than 0
    a) Set ct as the divided value of lat by r.
    b) Set st as the divided value of long by r.
    c) Set the X co-ordinate value as the product of the r value, the sum of the product of the ct with the cosine value of the angle with the sum of the product st with the Sin value of the angle.
    d) Similarly find the Y co-ordinate value as the product of the r value, the sum of the product of st with the cosine value of the angle with the sum of the product ct with the Sin value of the angle.
    e) Save the updated as the final X & Y value.
  5. End if
  6. Call find_angle to find the angle between depo and the customer.
  7. Call Find_diatance to find the distance between the 2 loctions.
  8. Return X,Y,angle and distance.

I coudn't solve the 4th and 5th point.. could you help me to form an equation to solve it

Upvotes: 0

Views: 851

Answers (2)

Thomas Matthews
Thomas Matthews

Reputation: 57749

Here is my interpretation of step 4.c:

Set the X co-ordinate value
x =

Set the X co-ordinate value as the product of:
x = ( ) * ( )

Set the X co-ordinate value as the product of the r value:
x = (r) * ( )

Set the X co-ordinate value as the product of the r value, the sum of:
x = (r) * ( ( ) + ( ) )

Set the X co-ordinate value as the product of the r value, the sum of the product of:
x = (r) * ( ( ( ) * ( ) ) + ( ) )

Set the X co-ordinate value as the product of the r value, the sum of the product of the ct:
x = (r) * ( ( (ct) * ( ) ) + ( ) )

Set the X co-ordinate value as the product of the r value, the sum of the product of the ct with the cosine value of:
x = (r) * ( ( (ct) * (cos( ) ) ) + ( ) )

Set the X co-ordinate value as the product of the r value, the sum of the product of the ct with the cosine value of the angle:
x = (r) * ( ( (ct) * (cos(angle) ) ) + ( ) )

Set the X co-ordinate value as the product of the r value, the sum of the product of the ct with the cosine value of the angle with the sum of the product st with the Sin value of the angle:
x = (r) * ( ( (ct) * (cos(angle) ) ) + ( (st) * (sin(angle) ) ) )

Removing unnecessary parentheses:
x = r * (ct * cos(angle) + st * sin(angle));

Upvotes: 4

arx
arx

Reputation: 16904

Latitude and longtitude are coordinates on a sphere. XY coordinates are typically coordinates on a plane. Converting between them doesn't make a lot of sense.

You can calculate the distance between two lat/long coordinates directly; this distance is known as the Great Circle distance. Several stackoverflow questions cover how to do this. Here's one.

If you're looking for the nearest neighbour, do you actually need the angle?

Upvotes: 1

Related Questions