The shortest way to resolve the sphere

I am trying to write an algorithm that does the following.

Given the current position (in azimuth and inclination) and the target position (again in A, I), in which direction should I move in order to travel along the shortest path. The return value may be something like a vector A = -1, i = +0.5, which can then be scaled for step size / time.

The shortest path can be found using a large circle , it is easy to visualize, but it is difficult to implement, as shown above, because my coordinate system is not continuous.

My coordinate system is as follows (imagine facing a sphere)

The azimuth is 0 ~ pi when moving along the equator along the front side, 0 ~ -pi when moving along the equator along the back side.

The slope is 0 ~ + pi when moving from the top to the bottom of the sphere.

So, given this inconsistent coordinate system, how do I create a decision function that says β€œincrease A” to move along the shortest path?

+6
source share
1 answer

You have several alternatives. The first is to use the Haversine formulation . There is some javascript source code here . This requires the use of a more traditional lat / bosom, where the equator is at 0 latitudes and the poles are +/- & pi; or +/- 90 Β° latitude (depending on your units) and longitude are in the range of [-180 Β°, 180 Β°) or [- ?,, pi]) again depending on your devices. You can repeatedly find the midpoint until you have an approximate path that matches your needs. The azimuth / slope vector will simply be the lat / lon difference between two adjacent points, although over time this is likely to cause an error if you reapply these lat / lon deltas to your agent's location.

Another approach that may work for you is to convert your spherical coordinates of your start and end location into Cartesian coordinates, call them points u b and u e for the start and end points. The normal vector v of the large circle connecting the two points is a cross product (i.e. v = u b x u e ) and angle? is simply an arccosine of the normalized inner product (i.e., the theta; = cos -1 (( u e βˆ™ u e ) / (| u b || u e )). Then you can use the quaternion rotation and iteration from 0 to & theta is near the vector v for the actual movement along the path With this approach, the actual instantaneous vector at some point p along the path is simply p x v , or you can simply approximate it using the Cartesian difference between two adjacent points along the path.

+3
source

Source: https://habr.com/ru/post/886955/


All Articles