PDA

View Full Version : Is there a formula to calculate the following?

Vector
17 Jan 2007, 07:30
Having longitude and latitude and then adding distance (kilometers) and coming up with new values for longitude and latitude.:banghead:

scruffyduck
17 Jan 2007, 11:24
Yes there is but you need bearing as well as distance to generate terminal co-ordinates. I do not have the code here with me now but if you do a Google search for spherical geometry you will probably find what you want. I think that is how I found the information originally :)

Vector
17 Jan 2007, 12:43
Yes there is but you need bearing as well as distance to generate terminal co-ordinates. I do not have the code here with me now but if you do a Google search for spherical geometry you will probably find what you want. I think that is how I found the information originally :)

Bearing yes.

I am not a Mathematician and I can't find exactly what I need so if you come across the formula some day please post or email it to me. I would be very greatful.

Manuel Ambulo
17 Jan 2007, 16:05
I recommend you to check this website:

http://williams.best.vwh.net/avform.htm

Have most usefull aviations formulaes, including the one you are looking for....hope this helps..

Best Regards,

Manuel Ambulo

Vector
22 Jan 2007, 06:30
Having longitude and latitude and then adding distance (kilometers) and coming up with new values for longitude and latitude.:banghead:

Could still use more help with this calculation.

Siggy
22 Jan 2007, 08:16
Here is an exmaple:

The following is a bit rough, and it is based on the earth being a globe I believe:

Let's start at lat1=45 deg, lon1=0 deg and add 2km, bearing 30 deg (=tc):

d = (2km / (2 * pi * 6378km) * 360 deg) = 0.01797 deg
(The 2 * pi * 6378km is the circumference of the earth approx.)

lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc) )

lat = asin(sin(45 deg) * cos(0.01797 deg) + cos(45 deg) * sin(0.01797 deg) * cos(30 deg))
= asin(0.70729880824) = 45.015561771 deg

lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi

lon = mod(0 deg - asin(sin(30 deg) * sin(0.01797 deg) / cos(45.015561771 deg) * 360 deg / (2 * pi)) + 180 deg, 360 deg) - 180 deg =
= mod(0 deg - asin(0.0002218341622887) + 180 deg, 360 deg) - 180 deg
= mod(-0.0127101613552102486 + 180, 360) deg - 180 deg =
= -0.0127101613552102486 deg

Then keep in mind that some people who live at 'negative' longitudes do not like that fact and modify formulas so their longitudes have positive values. So the new longitude is actually 0.0127101613552102486 deg east (positive).

Vector
22 Jan 2007, 14:59
Thanks Siggy!

Vector
23 Jan 2007, 10:53
Here is an exmaple:

The following is a bit rough, and it is based on the earth being a globe I believe:

Let's start at lat1=45 deg, lon1=0 deg and add 2km, bearing 30 deg (=tc):

d = (2km / (2 * pi * 6378km) * 360 deg) = 0.01797 deg
(The 2 * pi * 6378km is the circumference of the earth approx.)

lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc) )

lat = asin(sin(45 deg) * cos(0.01797 deg) + cos(45 deg) * sin(0.01797 deg) * cos(30 deg))
= asin(0.70729880824) = 45.015561771 deg

lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi

lon = mod(0 deg - asin(sin(30 deg) * sin(0.01797 deg) / cos(45.015561771 deg) * 360 deg / (2 * pi)) + 180 deg, 360 deg) - 180 deg =
= mod(0 deg - asin(0.0002218341622887) + 180 deg, 360 deg) - 180 deg
= mod(-0.0127101613552102486 + 180, 360) deg - 180 deg =
= -0.0127101613552102486 deg

Then keep in mind that some people who live at 'negative' longitudes do not like that fact and modify formulas so their longitudes have positive values. So the new longitude is actually 0.0127101613552102486 deg east (positive).

Well my brain-cloud must be acting up again. lolol
I can't get these two calculations to work in VB.Net correctly.

1. lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc) )

You show 'lat=45.015561771' as a result.
When using this statement in VB.Net I get 'lat=1.020217787680854'.

2. lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi

Your explanation of calculating lon is showing 360 and 180 degree values which are not shown in the above calculation.

The 'd = (2km / (2 * pi * 6378km) * 360 deg)' calculation for the new distance value is ok!

If you could explain a little more I would appreciate it.
Thanks.

lmoelleb
24 Jan 2007, 13:19
You are aware the .NET Math library use radians, not degrees?

Vector
24 Jan 2007, 18:12
You are aware the .NET Math library use radians, not degrees?

Yes I do !

ziporama
24 Jan 2007, 19:28
Could you post your code - that would greatly help Vector.

Classic computation problems include mixing precision or data types, so I would make sure all your variables are doubles, and that your radians are indeed radians and not degrees (as mentioned above).

Regards,

Etienne

Vector
30 Jan 2007, 08:06
Here is an exmaple:

The following is a bit rough, and it is based on the earth being a globe I believe:

Let's start at lat1=45 deg, lon1=0 deg and add 2km, bearing 30 deg (=tc):

d = (2km / (2 * pi * 6378km) * 360 deg) = 0.01797 deg
(The 2 * pi * 6378km is the circumference of the earth approx.)

lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc) )

lat = asin(sin(45 deg) * cos(0.01797 deg) + cos(45 deg) * sin(0.01797 deg) * cos(30 deg))
= asin(0.70729880824) = 45.015561771 deg

lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi

lon = mod(0 deg - asin(sin(30 deg) * sin(0.01797 deg) / cos(45.015561771 deg) * 360 deg / (2 * pi)) + 180 deg, 360 deg) - 180 deg =
= mod(0 deg - asin(0.0002218341622887) + 180 deg, 360 deg) - 180 deg
= mod(-0.0127101613552102486 + 180, 360) deg - 180 deg =
= -0.0127101613552102486 deg

Then keep in mind that some people who live at 'negative' longitudes do not like that fact and modify formulas so their longitudes have positive values. So the new longitude is actually 0.0127101613552102486 deg east (positive).

How do you write the following code in VB.Net?

What language is used in the following expression?