I have a geolocation represented using latitude and longitude: $({\phi_1,\lambda_1})$ and a given distance in meters $d$.
I want to find an equation for all the geolocations $({\phi_2,\lambda_2})$ that are approximately $d$ meters from the first location.
I won't be dealing with locations more than a few kilometers away from each other, and margin of error can be quite wide, so a rough approximation should be good enough.
I tried to adapt questions such as How to find a point on a line at a given distance from a given point on the same line (given the equation of the line)? and Triangulation algorithm for mobile geolocation detection , but I find it too hard to adapt to geolocation units.
I also tried to reverse the approximation equation from this reference, but could not simplify it enough:
$x=(\lambda_2-\lambda_1)\cos(\frac{\phi_1+\phi_2}{2})$
$y=\phi_2-\phi_1$
$d=\sqrt{x^2+y^2}R$
With $R$ being earth radius in meters 6371e3
Edit:
If anyone interested, javascript code based on the answer:
const toRadians = (value) => value * Math.PI / 180;
const toDegrees = (value) => value * 180 / Math.PI;
const R = 6371e3;
const getRandomLocation = ({latitude, longitude, distance}) => {
const degree = Math.floor(Math.random() * 360);
const noise = toRadians(degree);
const phi = toRadians(latitude);
const lambda = toRadians(longitude);
const randLatitude = toDegrees(phi + (distance / R) * Math.cos(noise));
const randLongitude = toDegrees(lambda + (distance / R) * (Math.sin(noise) / Math.cos(phi)));
console.info(`(${latitude},${longitude}) (${distance}m, ${degree}°)-> (${randLatitude},${randLongitude})`);
return {latitude: randLatitude, longitude: randLongitude};
};
A cartesian equation can be found from your last formulas. I'd only substitute $\cos(\phi_1+\phi_2)/2$ with $\cos\phi_1$: $$ (\phi_2-\phi_1)^2+(\lambda_2-\lambda_1)^2\cos^2\phi_1={d^2\over R^2}. $$ If you want an explicit formula you can solve for either angle, e.g.: $$ \phi_2=\phi_1\pm\sqrt{{d^2\over R^2}-(\lambda_2-\lambda_1)^2\cos^2\phi_1}. $$ Alternatively, you can introduce a rotation angle $\theta$ and write a parametric equation: $$ \phi_2=\phi_1+{d\over R}\cos\theta; \quad \lambda_2=\lambda_1+{d\over R}{\sin\theta\over\cos\phi_1}. $$ EDIT.
The above formulas work if the angles are expressed in radians: please make the appropriate conversions if the angles are given in degrees.