# Finding Relation Between Two Points on a Sphere

Basically I want to know how I can determine the general direction between two points on a sphere, that is, is point 2, north, west, east, or south of point 1. Don’t know what other info I need to add but how can I do this?

Let’s assume the frame of reference is the sphere and the local ‘y’ axis forms the poles (positive ‘y’ is north and negative ‘y’ is south). Further, lets assume you want the direction of the first step you would take following the shortest path between point 1 and point 2.

Step 1: convert the two points into local coordinates of the sphere. You can do that using Transform.InverseTransformPoint().

Step 2: Use Vector3.Slerp() to get a point just a bit along the path from point 1 to point 2.

``````var nextStep = Vector3.Slerp(localPoint1, localPoint2, 0.05);
``````

Step 3: Get a direction:

``````var dir = nextStep - localPoint1;
``````

if (dir.y) is positive, then the next step will be northerly. If dir.x is positive the next direction will be easterly. You will have to figure out how you want to handle the ratio between the two to detect N vs NE vs E for example. You could use Vector3.Angle() or Vector3.Dot() to figure that out.