python - Function not producing intended results? -


i having trouble trying figure out why 1 of functions isn't producing results expect. pretty sure has converting equation code can't pinpoint wrong exactly.

this given formula: d=radius * arccos(sin(x1)sin(x2)+cos(x1)cos(x2)cos(|y1-y2|)) http://img42.com/yftmc+

here code:

part1 = math.cos(abs(y1 - y2)) part2 = math.cos(x1) * math.cos(x2) part3 = math.sin(x1) * math.sin(x2) d = radius * math.acos(part3 + (part2 * part1)) return d 

you're giving values in degrees instead of radians math.sin, etc. functions expect. try converting values radians math.radians(degvalue).


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -