You could easily add these two lines of function definitions to your code.

    sind(x) = sin(degrees2radians(x))
    cosd(x) = cos(degrees2radians(x))

and your haversine function stands as is, not littered with conversions.


On Tuesday, February 4, 2014 6:55:13 PM UTC+1, Jacob Quinn wrote:
>
> As someone who doesn't have to work with the functions very often or deal 
> with degrees/radians conversions, I actually have found it convenient to 
> have the sind functions. It saves me time from having to remember what the 
> conversion is or make my code uglier littered with degrees2radians() 
> conversions, for example, in the following haversine distance calc.
>
> haversine(lat1,lon1,lat2,lon2) = 12745.6 * asin(sqrt(sind((lat2-lat1)/2)^2 
> + cosd(lat1) * cosd(lat2) * sind((lon2 - lon1)/2)^2))
>
>

Reply via email to