I have a coordinate in (lat/lon). I want to find a new coordinate shifted from this point by 'x' meters in the direction given by a compass bearing (degrees). The distance offset I am hoping to calculate will be fairly small, anywhere from 4-10 m, so I will need a fair amount of accuracy.
This is an interesting question.
The simplest approach is a numerical integration -- divide the path up into 10 meter segments, for example, and use a simple approximation for each point.
- the change in latitude is the sine of the heading (90 deg == north) times the distance times the conversion factor from distance to radians (π / 20000 km).
- calculate an average value of cosine over he interval. A simple approximation is the cosine of the average latitude.
- the change in longitude is the cosine of the heading (0 deg == east) times (π / 20000 km) divided by the cosine.
- check to make sure you didn't cross a pol (cosine of the latitude < 0). If you did, then it's an error. There's no such thing as heading north from the north pole.
Do capture the whole distance in one shot is extremely challenging mathematically, however, since consider a route heating 5 degrees north of east from 1 mm north of the south pole to 1 mm south of the north pole. It will be a spiral of increasing, then decreasing radius.