comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: What is the problem ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: What is the problem ? [message #68386] Wed, 28 October 2009 18:56 Go to previous message
Ruby is currently offline  Ruby
Messages: 2
Registered: October 2009
Junior Member
On 10月28日, 下午2时58分, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Oct 27, 8:28 pm, Ruby <wuqiao...@gmail.com> wrote:
>
>
>
>> I wrote a simple program to caculate the distance between two location
>> (lon1,lat1), (lon2,lat2)
>
>> function earth_dis ,lon1,lon2,lat1,lat2
>
>> b1 = !pi*lat1/180.0
>> b2 = !pi*lat2/180.0
>> a1 = !pi*lon1/180.0
>> a2 = !pi*lon2/180.0
>
>> dis = 6378.1*acos( cos(b1)*cos(b2)*cos(a1-a2)+sin(b1)*sin(b2))
>
>> RETURN,dis
>> END
>
>> But When I tried to test the program, the results turned to be like
>> IDL> print,earth_dis(4.0,4.0,4.0,4.0)
>>          -NaN
>> IDL> print,earth_dis(8.0,8.0,8.0,8.0)
>>       2.20215
>
>> In both cases, the result should be straightforwardly equal  0. Then
>> what is the problem with my program or IDL ?
>
> Check out the wikipedia entry on great circle distances:http://en.wikipedia.org/wiki/Great-circle_distance
>
> The formula you use doesn't work well on a computer with the distance
> is small (roundoff errors become large). They reference a better
> formula. Alternatively, use the GCIRC function in the IDL Astronomy
> user's library.
>
> Chris

thanks, both of you
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: quadtree algorithm
Next Topic: Re: Invalid indices?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:16:48 PDT 2025

Total time taken to generate the page: 0.00176 seconds