Math help needed - Warning complex equation!!....read only if brain is in stable conditon

Tamagotchi tgotchi at hotmail.com
Mon Feb 24 02:53:59 EST 2003


Free distance calculation source codes are available here.
http://www.zipcodeworld.com/developers.htm

grayrest <grayrest at grayrest.com> wrote in message news:<b1tund$cjm$1 at news-int.gatech.edu>...
> Jay wrote:
> > right, now that I got your attention, I need help on the following
> > piece of python code:
> > 
> > distance = 1.15 * (180 * (acos((sin(pi * lat1 / 180) * sin(pi * lat2 /
> > 180)) + (cos(pi * lat1 / 180) * cos(pi * lat2 / 180) * cos(pi * (lon2
> > – lon1) / 180))) / pi) * 60)
> > 
> > when trying to compile I get the error "SyntaxError: invalid syntax".
> > 
> > Uses Math libray, pi is a defined constant (lat1, lat2, lon1, lon2 are
> > variables - two sets of latitude and longitude values)
> > 
> > Using Linux Red Hat 8.0, Python 2.2.2
> > 
> > I've counted the number of brackets (11 in total both sides) there and
> > they do match, so I can't really see anything obviously wrong with
> > this.
> > 
> > there is a handsome reward available for the solution
> > provided....(hehehhe)
>  >>> def rad(deg): return 180.*deg/pi
>  ...
>  >>> lat1,lon1,lat2,lon2=60.78,  161.80, 66.92, 151.52
>  >>> lat1
>  60.780000000000001
>  >>> 
> distance=1.15*(180*(acos((sin(rad(lat1))*sin(rad(lat2)))+(cos(rad(lat1))*cos(rad(lat2)) 
> * cos(rad(lon2 -lon1))))/pi)*60)
>  >>> distance
> 328.4917120736846
> 
> Taadaa! I'm pretty sure it's the "-" as has already been suggested. I'd 
> also break it up if I could to make it more readable.




More information about the Python-list mailing list