[Math] Discretize a circle on a sphere with a given center and radius

spherical coordinatesspherical-geometry

I would like to draw a discretized circle on the surface of a sphere (the Earth in that case).

The input of the algorithm would be the center of the circle (expressed as longitude and latitude), the radius (expressed in meters), and the number of points to calculate.

The output would be the coordinates of each calculated point.

I am guessing this involve the Great Circle formula but I can't see how. Any help would be appreciated.

Regards

Best Answer

The easiest way to do this would probably be to first find the coordinates of a circle at one of the poles, and then use rotation matrix transforms to move the circle to the desired location. At a pole, the points have coordinates: $$(r\cos\phi,r\sin\phi,\sqrt{R^2-r^2})$$ Which you can evenly space by using $\phi=2n\pi/N$. Once you have an array of points, you want to transform each point by rotating it around the $X$ axis $\pi-\theta_{lat}$ degrees, and then around the $Z$ axis $\phi_{long}$ degrees.