import math


def heading(long1, lat1, long2, lat2):
	"""
	heading(long1, lat1, long2, lat2)
	input coordinates in degrees
	output heading in degrees
			0
	270	  		   90
		   180
	"""
	dlong = long2 - long1
	dlat = lat2 - lat1
	#convert everything to radians
	for coord in [dlong, dlat, long1, long2, lat2, lat2]:
		coord = math.radians(coord)
	heading = math.atan2(math.sin(dlong)*math.cos(lat2), math.cos(lat1)*math.sin(lat2) - math.sin(lat1)*math.cos(lat2)*math.cos(dlong))
	heading = math.degrees(heading)
	heading = (heading + 360) % 360
	return heading