math - Shortest path on a sphere direction descision -


i'm trying write algorithm following.

given current position (in azimuth , inclination) , target position (again in a, i) in direction should travel travel on shortest path. return value vector = -1, = +0.5, can scale step size/time.

the shortest path can found using a great circle, easy visualize, it's hard implement above because coordinate system isn't continuous.

my coordinate system followed (imagine standing in front of sphere)

the azimuth 0 ~ pi when traveling along equator along front side, it's 0 ~ -pi when traveling along equator along rear side.

the inclination 0~+pi when traveling top bottom of sphere.

so given non-continuous coordinate system, how create decision function says 'increase a' travel on shortest path?

you have couple of alternatives. first use haversine formulation. there javascript source code here. requires using more traditional lat / lon equator @ 0 latitude , poles @ +/- π or +/- 90° latitude (depending on units) , longitude in range [-180°, 180°) or [-π, π) again depending on units. can repeatedly find midpoint until have approximate path suites needs. azimuth / inclination vector difference in lat / lon between 2 adjacent points, though on time induce error if repeatedly apply lat / lon deltas location of agent.

another approach may work transform spherical coordinates of starting , ending location cartesian coordinates, call them points ub , ue beginning , end points. normal vector v of great circle connecting 2 points cross product of 2 (i.e. v = ub x ue) , angle θ arccosine of normalized inner product (ie. θ = cos-1( (ueue) / (|ub||ue)). can use quaternion rotation , iterate 0 θ vector v navigate path. approach, actual instantaneous vector @ point p along path p x v, or can approximate using cartesian difference between 2 adjacent points along path.


Comments