You'll need to do the calculations in an external, where you can use double precision.
And..... TADA! Here's the external. I just copied in the C code from the Rosettacode link you sent. It gives 2887.26 as the result now.
The external code is here: https://github.com/jwmatthys/haversine-pd
I built the linux version already. It should be easy to build others.
Joel
On 06/06/2015 09:48 PM, Max wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Merci Cyrille,
in the formula the intermediate steps are quite small fractions and it seems their precision is important. In the test case the Pd implementation is 8917.74 km off the proper result (2887.26). However I need a precision of about 1m.
So I assume the haversine formula is not implementable in Pd at all? (unless double precision will be there that is)
Or is there a workaround?
m.
On 2015년 06월 07일 05:05, Cyrille Henry wrote:
hello,
pow 2 did not like negative number. use "t f f" and "*" in order to compute the square of a number.
i correct 2 of your formula according to what i found in your link. they both gives the same result : 11805 the same value computed with your 2nd link gives 12210. for other value, it also look close. so i guess the difference is number precision.
cheers c
Le 06/06/2015 20:18, Max a écrit :
I tried to implement the Haversine formula in Pd which should give you the distance in km between two lat long coordinates.
https://en.wikipedia.org/wiki/Haversine_formula http://www.movable-type.co.uk/scripts/latlong.html
One huge obstacle is the imprecision of the 32bit floats, but even without that I can't get the formula to work. I kept 3 failed implementations in the test-case.
http://rosettacode.org/wiki/Haversine_formula
Could someone give me a hand please?
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1
iEYEARECAAYFAlVzsO0ACgkQ3EB7kzgMM6KETQCfRvgOmpqbmyhZaH2Y5hzsRHlC XOgAnR+6lqxJfjTj5k7vR747UU8ATrqA =pBZv -----END PGP SIGNATURE-----
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list