I need to find the latitude and longitude coordinates of the four corners of a rectangle in a Python script, given the center coordinate, length, width, and bearing of the shape. Length and width are in statute miles, but honestly converting those to meters is probably one of the easiest parts. I have some examples of how to use haversine to calculate distance between 2 points, but I'm at a loss on this one. Would anyone be able to at least point me in the right direction?
Update
This is the formula I came up with for my Python script, based on the link that @Mbo provided:
lat2 = asin(sin(lat1)*cos(length2/(_AVG_EARTH_RADIUS_KM)) + cos(lat1) * sin(length2/(_AVG_EARTH_RADIUS_KM)) * cos(bearing1))
lon2 = lon1 + atan2(sin(bearing1) * sin(length2/(_AVG_EARTH_RADIUS_KM)) * cos(lat1), cos(length2/(_AVG_EARTH_RADIUS_KM)) - sin(lat1) * sin(lat2))
Unfortunately the results don't make sense. I used a center point of 32° N 77° W, length of 20 miles, width 10 miles, and bearing 0 deg and I'm getting the result 0.586599511812, -77.0.
When I plot it out on my mapping application, it tells me that the coordinate for the new point should be 32.14513° N, -77.0° W.
Edit to add: I converted length1 and width1 to kilometers, and converted bearing1 to radians before using in the formulas above.