# Quaternion (Ray cast) from one Lat/Long to the Lat/Long through the earth on the other side

I very new to this and apologize for what is probably a pretty silly question. Not even sure I’m using the correct terms. Still trying to wrap my head around much of this math.

What I’m attempting to do and would appreciate some hints is the following:

Input: From a Lat/Long Geo position using Quaternion as a ray cast.

Output: Lat/Long Geo position as a ray cast from the input values to the other side of the globe.

I’m not looking for anything super accurate but roughly close.

This illustration my better clarify what I’m trying to do:

The position on the exact opposite side of the Earth is called the antipode. Given a latitude and longitude of an initial point, you can find the antipode by inverting the latitude and offsetting the longitude by 180 degrees (with normal wrap-around rules for longitude). In other words, X degrees north becomes X degrees south (and vice versa), and Y degrees east becomes (180-Y) degrees west (and vice versa).

I don’t understand how quaternions or raycasting fit into your question.

1 Like

You’re looking for a line/sphere intersection test. Here’s the wikipedia page for the equation: https://en.wikipedia.org/wiki/Line–sphere_intersection

And here’s some code from stackoverflow: https://stackoverflow.com/questions/5883169/intersection-between-a-line-and-a-sphere

Any line/sphere intersection will give you two points (unless the line is tangent or doesn’t intersect), so to get the far point you will need to do a distance check between your starting point and the results and pick the farthest one.

3 Likes

This is not always exactly straight down. It will be based on the orientation of my phone. I can angle it up higher and get an intersection to a nearby city that is below my horizon or angle it lower and get a farm on the other side of the globe.

Excellent resources! Thank you! Very helpful!