5 added 69 characters in body

I am programming an algorithm where I have broken up the surface of a sphere into grid points (for simplicity I have the grid lines are parallel and perpendicular to the meridians). Given a point A on the sphere, I would like to be able to efficiently take any grid "square" and determine the point B in the square with the least spherical coordinate distance AB.

• Near the poles, the "squares" degenerate into "triangles".
• As noted by Trithematician, this is a special case of to finding the shortest distance from a point to an arc on a sphere. For the longitudinal lines, these are arcs of great circles, but for the latitudinal they are not.
• TonyK provides a method below that solves the longitudinal case.
• Minimising the distance in 3d also minimises the distance on the sphere

I actually asked this question here: http://stackoverflow.com/questions/1463606/closest-grid-square-to-a-point-in-spherical-coordinates and decided to use an approximation instead, but I am still curious as to whether there is an exact solution. I thought that since this is really more of a maths question than a programming question that I would repost it here.

4 added 99 characters in body; deleted 4 characters in body; deleted 1 characters in body

I am programming an algorithm where I have broken up the surface of a sphere into grid points (for simplicity I have the grid lines are parallel and perpendicular to the meridians). Given a point A on the sphere, I would like to be able to efficiently take any grid "square" and determine the point B in the square with the least spherical coordinate distance AB.

• In

• Near the degenerate case poles, the "squares" are actually degenerate into "triangles".
• As noted by TriamathemacianTrithematician, this is a special case of to finding the shortest distance from a point to an arc on a sphere. For the longitudinal lines, these are arcs of great circles, but for the latitudinal they are not.
• Minimising the distance in 3d also minimises the distance on the sphere

I actually asked this question here: http://stackoverflow.com/questions/1463606/closest-grid-square-to-a-point-in-spherical-coordinates and decided to use an approximation instead, but I am still curious as to whether there is an exact solution. I thought that since this is really more of a maths question than a programming question that I would repost it here.