Problem with angles between lat and longitudes when using the atan function

I'd greatly appreciate any help.

I'm sure they can help you at http://snippets-r-us.com.