1

I'm implementing a simulation in Java using a GIS (WGS84). I want to place my agents shifted to each other. The latitude is easy 1 m is 1/111000 degrees. But I want to shift an agent on the longitude side I have to consider earth curvature (I guess!).

I found this formula on Wiki: a= (2*pi*r*cos(phi))/360

r  : radius
phi: latitude
a  : should be the distance

I tried now multiply my distances to 1/a, but the positions are not logical!

mmdemirbas
  • 9,060
  • 5
  • 45
  • 53
  • 1
    You can use the formula from [this question](http://stackoverflow.com/questions/7222382/get-lat-long-given-current-point-distance-and-bearing). When you set bearing to 0 you can get the longitude angle for a given distance and latitude. – Vatev Jul 30 '12 at 14:41

2 Answers2

0

Is it your goal to calculate the distance between your two points?

I would use:

d(P1, P2) = ((r · pi)/180)) · cos−1 (cos(a1) · cos(a2) · cos(b1 − b2) + sin(a1) · sin(a2))

where d is distance, r would be the earth radius, cos-1 is the inverse cosinus and a1,a2,b1,b2 are the angles of your 2 agents

If you know the vertical and horizontal distance (l and h), you can simply calculate b1 = a1 - l/(2*pi*r*cos(angleFromEquator)*360) and a2 = h/(2*pi*r*360) + b2 if you are using spherical coordinates.

If you are at the equator (latitude = 0) and you shift 1.000 km to the east, you would end up ( 1.000 km / 40.000 km ) * 360° = 9° further east.

At a latitude of 45°, that would be ( 1.000 km / 28.000 km ) * 360° = 12.8°

Jonas Eicher
  • 1,413
  • 12
  • 18
  • I know the vertical and horizontal distanaces and want the angles! – user1563153 Jul 30 '12 at 14:55
  • I mean I know the vertical and horizontal distance to agent b and want its angles by using the angles of agent a! – user1563153 Jul 30 '12 at 15:00
  • latitude is no different than longitude in that matter – Jonas Eicher Jul 30 '12 at 15:23
  • So if I have an Agent A on the position angle (a1,a2) and I want Agent B on the shifted position 1m(vertical) and 2000m (horizontal). Would my new positions be: b1 = a1 - (1*1/111000) and b2 = a2 - (2000*1/111000) ??? – user1563153 Jul 30 '12 at 15:38
  • ahh now I see what I forgot. That would be true on the equator, but if you are on a different angle, you have to multiply by cos(angleFromTheEquator) – Jonas Eicher Jul 30 '12 at 16:01
  • Why do I have to use the "angleFromEquator"? Shouldn't it be the angle b2? – user1563153 Jul 30 '12 at 18:11
  • @ b2 = a2 - h/(2*pi*r*360) means: Is r always the earth radius at the equator (6378137 m) or avarage radius (6371000.785 m)? If I have the longitude a2 = 52.308056 in decimal and the horizontal distance h = 40m could I still use the the formula? Because then I receive the same angle, due to the very small value of h/(2*pi*r*360)! – user1563153 Jul 30 '12 at 18:41
  • angleFromTheEquator = latitude = angle b2 – Jonas Eicher Jul 31 '12 at 07:50
  • the distance per degree is 40.000km/360° for latitude, but for the longitude, the circumference of earth is 40.000km only at the equator. So the distance per degree varies, depending on the latitude you are at. At 45° latitude for example, it would be 40.000km *cos(45) = 28.000 km. So your distance would be 28.000km/360 degrees – Jonas Eicher Jul 31 '12 at 07:59
  • Is it right that the circumference Uc on each latitude is Uc = 2*pi*6378000*cos(currentLatitude) and then the distance formula d would be d= (Uc*cos(currentLatitude))/360? My new longitude would be (if I shift the position 2000m b2 to the east) then b2 = a2 - 2000/d ? So if a2 = currentLatitude = 52.308056, then Uc=24501971.49m ,d=41613.59 m and b2=52.25999478 ? – user1563153 Aug 01 '12 at 07:23
  • In your example you shifted along the North-South-axis. – Jonas Eicher Aug 01 '12 at 13:36
  • If Latitude = 52, Longitude = 0 and you shift 41 km to the east, you would be at a longitude of 0.6 degrees – Jonas Eicher Aug 01 '12 at 13:37
  • I added an example to my answer – Jonas Eicher Aug 01 '12 at 13:42
  • Oh sorry my longitude a1 is 4.764167 then b1 = a1 - 2000/d = 4.716105 ? – user1563153 Aug 02 '12 at 07:14
  • Which formula do you use, because I get 0.9717 using your example on my formulas above! – user1563153 Aug 02 '12 at 07:32
  • wait, I think you are confusing things. Its only: `Uc = 2*pi*6378000*cos(currentLatitude)` And then `b1 = a1 - ( (2000m / Uc) * 360° )` – Jonas Eicher Aug 06 '12 at 10:12
  • I found this formula on Wiki (http://de.wikipedia.org/wiki/Geographische_L%C3%A4nge) d= (Uc*cos(currentLatitude))/360 so I thougth it have to be right?! Can you send me a link for verfication, cause it is quite important for my work to have aqurate references? – user1563153 Aug 06 '12 at 17:47
  • It's the same formula I got it know! Thanks a lot! – user1563153 Aug 07 '12 at 06:41
0

If you'll move 1Km east, and then 1Km north, you'll reach a different location than if you'll move 1Km north and then 1Km east.

On extreme cases (specific latitudes near the north pole), moving 1Km east will bring you back to your original location.

Your concept of separating latitudinal and longitudinal 'shift' is wrong, since it is not suitable for locations on the surface of a sphere/ellipsoid.

Anyway, if your are looking for the earth's circumference at a given latitude, and a spherical model is accurate enough for your needs, look here.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Lior Kogan
  • 19,919
  • 6
  • 53
  • 85