Re: angle between two points

From: Michael Notaro <mnotaro_at_nyahnyahspammersnyahnyah>
Date: Fri Jun 03 2011 - 13:16:42 MDT

This worked ok. Probably not the most elegant approach.

lat1 = 40.
lon1 = -90.
lat2 = 35.
lon2 = -85.

quad=new((/1/),integer)

; 4 1
; 3 2

if ( (lat2.gt.lat1).and.(lon2.gt.lon1) ) then
  quad=1
end if
if ( (lat2.lt.lat1).and.(lon2.gt.lon1) ) then
  quad=2
end if
if ( (lat2.lt.lat1).and.(lon2.lt.lon1) ) then
  quad=3
end if
if ( (lat2.gt.lat1).and.(lon2.lt.lon1) ) then
  quad=4
end if

gcdist = gc_latlon(lat1,lon1,lat2,lon1,10,4)
dist1=(/gcdist(0)/)
gcdist = gc_latlon(lat2,lon1,lat2,lon2,10,4)
dist2=(/gcdist(0)/)
angle=atan(dist2/dist1)*180./3.1416

if (quad.eq.2) then
  angle=180-angle
end if
if (quad.eq.3) then
  angle=180+angle
end if
if (quad.eq.4) then
  angle=360-angle
end if

print(angle)

On Jun 3, 2011, at 11:01 AM, Michael Notaro wrote:

> In NCL, how can I compute the angle in degrees between two lat/lon points?
> Let's say I have lat1,lon1 and lat2,lon2. Let's say the wind is blowing from
> lat2,lon2 to lat1,lon1. How do I compute the wind direction in degrees?
>
> Thanks, Michael
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jun 3 13:16:52 2011

This archive was generated by hypermail 2.1.8 : Thu Jun 09 2011 - 14:56:48 MDT