SDK Question Distance calc overrun ?

If you pick two points 90 degrees apart, you know the distance: dis = 2*pi*rad/4. So if the two codes give you different results for this case, at most one can be correct, and you can validate directly with the known truth.

(Kourou --> Overberg - Best I could do)
Yours: 8811 km great circle distances
Mine: 9255 km (Only 5% diff now, not 11% ? )

True ?: 10,007.54339801029 km (but this is straight line distance isn't it ? ^ ^ ^ )
 
For the great circle distance between Kourou (Long=-52.73, Lat=5.2) and Overberg (Long=+20.32, Lat=-34.58) I get dis=8.8052e3 with both our codes, which also agrees with the MFD display. This doesn't seem to match either of your results, but at least corresponds approximately to 8811. Maybe the vessel wasn't parked exactly on the base's reference point?

9255 is however significantly different. Can you explain in detail how you got to that value?
 
9255 is however significantly different. Can you explain in detail how you got to that value?

It's just by compiling with "my code".......
Am I on the same page here ?

I get dis=8.8052e3 with both our codes, which also agrees with the MFD display.

Don't understand how this happens.....

Hope I'm not leading you a merry dance here..........
 
We'll get there eventually :lol:
Code used:
Code:
dis = sin((latitude)*RAD) * sin((tgtlat)*RAD) + cos((latitude)*RAD) * cos((tgtlat)*RAD) * cos((longitude-tgtlng)*RAD);
  dis = acos(dis);
  dis = (dis)*DEG;
  dis = dis * 6371;

So, step by step, this is what I get (leaving out dis = (dis)*DEG;, which I hope we agree is incorrect):

Code:
latitude = 5.2
longitude = -52.73
tgtlat = -34.58
tgtlng = +20.32
dis = sin((latitude)*RAD) * sin((tgtlat)*RAD) + cos((latitude)*RAD) * cos((tgtlat)*RAD) * cos((longitude-tgtlng)*RAD) = 0.1876
dis = acos(dis) = 1.3821
dis = dis*6371 = 8.8052e3
whereas you ... ?
 
(leaving out dis = (dis)*DEG;, which I hope we agree is incorrect):

Well, only way I can get significant reading is by including dis = (dis)*DEG;

I then get 9248.97, otherwise it's a silly 165

Sorry, but I've gotta hit the sack now but this is doing my head in, so we need to get to the bottom of it.
Thanks for all so far...:tiphat:
 
Well, only way I can get significant reading is by including dis = (dis)*DEG;
Ok, I'm awake now and have remedied my mistake.

Checks out to 8805.18 in my environment (don't have Matlab)
 

Attachments

  • Check.png
    Check.png
    118.7 KB · Views: 13
Back
Top