Reputation: 19
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
I coudn't solve the 4th and 5th point.. could you help me to form an equation to solve it
Upvotes: 0
Views: 851
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
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