import math


def calculateGridPositionFromRangeBearing(easting, northing, distance, bearing):
	"""given an east, north, range and bearing, compute a new coordinate on the grid"""
	point =   (easting, northing)
	angle =   90 - bearing
	bearing = math.radians(bearing)
	angle =   math.radians(angle)

	# polar coordinates
	dist_x = distance * math.cos(angle)
	dist_y = distance * math.sin(angle)

	xfinal = point[0] + dist_x
	yfinal = point[1] + dist_y

	# direction cosines
	cosa = math.cos(angle)
	cosb = math.cos(bearing)
	xfinal = point[0] + (distance * cosa)
	yfinal = point[1] + (distance * cosb)

	return [xfinal, yfinal]