# Definition of a line between two points on a sphere

1. Mar 28, 2010

### TravelGirl

I have two points on a sphere (x1,y1,z1) and (x2,y2,z2).
Now I want to plot a straight line over the surface of the sphere between these point.

The radius and the center of the sphere are also known.

What should be the equation of this line?

2. Mar 28, 2010

### tiny-tim

Welcome to PF!

Hi TravelGirl! Welcome to PF!

If you know the Cartesian coordinates of the centre of the sphere, then just define the circle with that centre that goes through those two points.

3. Mar 29, 2010

### TravelGirl

Thanks Tim for your welcoming words.

I do have the Cartesian coordinates of the two points on a sphere.
Only I do not want to define a circle, but a line between these two points alon the surface of the sphere.

How do I do this?

4. Mar 29, 2010

### Office_Shredder

Staff Emeritus
The shortest path between two points on a sphere is along the great circle on the sphere passing through them, which is what tiny-tim described

5. Mar 29, 2010

### TravelGirl

Yes, I do know the great circle equation. But this gives me only the length of the line between these two points.

What equation/parameters do I use when I want to plot the line between these points?
(sorry if I don;t understand it)

6. Mar 29, 2010

### haushofer

You could solve the geodesic equation on a sphere, but the outcome will be that the geodesic is a great circle, so we save you some time :P

7. Mar 29, 2010

### tiny-tim

That is the equation you're looking for …

as Office_Shredder and haushofer say, the great circle equation is the straight line over the surface of the sphere between those two points.
I don't understand what you mean

why doesn't your great circle equation gives you the whole circle?

8. Mar 29, 2010

### TravelGirl

I am sorry that I made you confused.

But I need to plot a line between these two points.

So I need some sort of parametric equations:
x=
y=
z=

I know that the great circle distance formula can give me the length between these two points, measured along the surface.

Can you maybe help me on these parametrix equations?

9. Mar 29, 2010

### tiny-tim

I'm not talking about a distance formula, I'm talking about the equation of the circle.

Do you know the equation for a circle of a given radius with a given centre?

10. Mar 29, 2010

### TravelGirl

Yes, this should be something like:

x=x0 +r*sin(theta)*cos(rho)
y=y0 +r*sin(theta)*sin(rho)
z=z0 +r*cos(theta)

But this is just a general circle, how do I make one which goes through my two points?
And describes the line between my two points and not the whole circle.

11. Mar 29, 2010

### tiny-tim

Well, you know what r is, so for example you can choose θ = 0 to be the direction from the centre to A, and you can choose θ = π/2 to be the perpendicular direction in the plane of A B and the centre.

12. Mar 29, 2010

### TravelGirl

I am starting to feel really dum, but appriciate your help very much.

Because by using constants, you get just one coordinate out of the parametric equation. So I must have understand your answer incorrectly.

How do I determine the perpendicular direction in the plane of A B and the centre?
And how do I get a range of numbers in my parametric equation?

13. Mar 29, 2010

### tiny-tim

Show us what you have so far.

14. Apr 6, 2010

### Rasalhague

As it's been a few days since the last post in this thread, I hope it's okay if I suggest a couple of methods. I found the first http://mathforum.org/library/drmath/view/52070.html". It's simpler than the one I thought of, but doesn't work when the points are at opposite poles. I'm just a learner myself, so don't take these as definitive answers. There may be neater or better ways of solving it; all comments welcome.

Look away now, if you prefer not to see such a full working out.

(1) If P and Q are position vectors from the centre of a sphere (of radius R) to two points on its surface, provided the points aren't directly opposite each other, you could write a parametric equation for a geodesic (that is: great circle segment, the shortest distance along the surface of the sphere) from point P to point Q like this

$$\textbf{R}(t)=R\frac{\textbf{P}+t\left ( \textbf{Q}-\textbf{P} \right )}{\left \| \textbf{P}+t\left ( \textbf{Q}-\textbf{P} \right ) \right \|}$$

where $t \in [0,1]$ (that is: t runs from 0 to 1, inclusive), so that $\textbf{R}(0) = \textbf{P}$, and $\textbf{R}(1) = \textbf{Q}$.

The expression $\textbf{P}+t\left ( \textbf{Q}-\textbf{P} \right)$ is a parametric equation for a line segment from P to Q in Euclidean 3-space, which goes under the surface of the sphere; that's to say, a representative position vector standing for each point on the line segment. The denominator is the magnitude of that position vector. Dividing a vector by its magnitude gives a unit vector in the same direction. If we multiply this unit vector by R, the radius of sphere, we get the required position vector for a point on the surface of the sphere.

This method fails when points P and Q are on opposite sides of the sphere. Then the line connecting them goes through the centre of the circle, and there are infinitely many possible geodesics between them. To get around this, you could offset P slightly in the direction you want the geodesic to go. Or maybe someone knows a more elegant way?

(2) Alternatively, you could describe the great circle segment in terms of a unit vector in the direction of P and another unit vector at right angles to P in the plane containing P, Q and the centre of the sphere. If P and Q are not exactly opposite each other, define unit vectors thus:

$$\textbf{e}_1=\frac{\textbf{P}}{\left \| \textbf{P} \right \|}=\frac{\textbf{P}}{R}$$

$$\textbf{e}_2=\frac{(\textbf{P}\times \textbf{Q})\times \textbf{P}}{\left \| (\textbf{P}\times \textbf{Q})\times \textbf{P} \right \|}$$

$$\textbf{e}_3=\frac{\textbf{P}\times \textbf{Q}}{\left \| \textbf{P}\times \textbf{Q} \right \|} = \frac{\textbf{P}\times \textbf{Q}}{R^2 \sin ( \textbf{P},\textbf{Q} )}$$

where $\sin ( \textbf{P},\textbf{Q} )$ is the sine of the angle from P to Q. The last of these is a unit vector normal to the plane in which the great circle lies. If P and Q are opposite each other, you can choose an arbitrary unit normal vector $\textbf{e}_3$, depending on which of the infinitely many great semicircles you want to describe from P to Q (the only condition is that it must be at right angles to P or Q, in other words $\textbf{P} \cdot \textbf{e}_3=0$), then define the $\textbf{e}_2$ in terms of the others:

$$\textbf{e}_2=\textbf{e}_3 \times \textbf{e}_1$$

In either case,

$$\textbf{R}(\theta)=R\left [ \left ( \cos \theta \right ) \textbf{e}_1 + \left ( \sin \theta \right ) \textbf{e}_2 \right ],$$

where $\theta$ runs from 0 to the angle between P and Q, which we can get from the definition of the dot product:

$$\theta \in \left [ 0,\arccos \left ( \frac{\textbf{P} \cdot \textbf{Q}}{R^2} \right ) \right ].$$

When P and Q are opposite, the direction is determined by the normal vector to the plane of rotation, $\textbf{e}_3$.

Last edited by a moderator: Apr 25, 2017