What is the formula for calculating the distance between two points on a torus?
Assume u is the angle of revolution around the z-axis, v is the angle on the small generating circle (with v = 0 at the middle of the torus pointing outward), R is the radius of revolution, and r is the radius of the generating circle. The metric of the torus is thus:
ds^2 = (R + r cos v)^2du^2 + r^2dv^2
But, in order to find the distance between two points on a metric, you need the geodesics, which I don’t know how to find because I never did figure out Christoffel symbols. If you have two points (u1, v1) and (u2, v2) on the torus, what is the distance formula?
I’m not doing homework; this is just for my own curiosity. Even if a closed-form expression does not exist, I have no idea where to begin to calculate even the form of the integral. I know that geodesics involve differential equations, but surely a 2-dimensional torus doesn’t actually require you to calculate all the Christoffel symbols, does it? This isn’t general relativity, after all.
Does that give you a flat metric? If it does, then the easiest thing to do is to measure the distance in the universal cover. That is, in the plane. The distance between two points will be their Euclidean distance.
There is a flat metric on the torus, but the OP’s metric (the metric for the standard embedding in R[sup]3[/sup]) isn’t it. The inner ring of the torus pretty clearly has negative curvature, while the outer ring has positive curvature.
For the OP, what problems are you having with the Christoffel symbols? In two dimensions, there aren’t very many of them, and you can just churn through all 8 if you want. Here the only nonconstant metric tensor component is g[sub]uu/sub=(R+r cos v)[sup]2[/sup], so the only nonzero [symbol]G[/symbol] components are [symbol]G[/symbol][sup]u[/sup][sub]uv[/sub]=[symbol]G[/symbol][sup]u[/sup][sub]vu[/sub] and [symbol]G[/symbol][sup]v[/sup][sub]uu[/sub].
So then it’s pretty easy to write down a differential form for the geodesic equation, if that’s what you’re aiming for:
0 = u’’ + 2[symbol]G[/symbol][sup]u[/sup][sub]uv[/sub]u’v’
0 = v’’ + [symbol]G[/symbol][sup]v[/sup][sub]uu/sub[sup]2[/sup] .
Post what you get for the Christoffel symbols and we’ll go from there.
You’re right. I confess that I skimmed, saw that there were metrics, and then panicked. I had this vision of being chased by a whole fleet of \Gamma’s. I need to lie down.
g[sub]uu,v[/sub] is the partial derivative of (R + r cos v)[sup]2[/sup] with respect to v, which is 2*(R + r cos v)*(-r sin v).
g[sup]uu[/sup] has superscripts, so it’s the du[sup]2[/sup] component of the multiplicative inverse of the metric’s matrix. The inverse of a 2x2 diagonal matrix is the easiest thing in the world, so g[sup]uu[/sup] = (R + r cos v)[sup]-2[/sup]. There are no du*dv terms in the metric, so g[sup]uv[/sup] is zero, so:
[symbol]G[/symbol][sup]u[/sup][sub]uv[/sub] = (-r sin v) / (R + r cos v).
OK, good, that’s what I get too. Now you’ve got a pair of ugly differential equations. But you can further simplify these. The first one is immediately separable: write
u’’/u’ = v’ * (2 r sin v)/(R + r cos v)
and you can actually integrate both sides with respect to time.
This is easier to see if you write g[sub]uu[/sub]=f(v); then this equation turns into
u’’/u’ = - v’ * f’(v)/f(v)
which integrates to
log u’ = log k - log f(v)
u’ = k / f(v) = k / (R + r cos v)[sup]2[/sup]
where k is an integration constant.
Now you can substitute this expression for u’ into the second equation to get a second-order ODE for v, which looks something like
0 = v’’ + h(v)
where h is some ugly function of v. There is a trick for performing the first integral of equations of this form; multiply through by v’ to get
0 = v’’ v’ + v’ h(v)
and you can now integrate this to
0 = (v’)[sup]2[/sup]/2 + H(v) + C
where H’=h and C is another integration constant. If you followed the hint in the spoiler, you can pretty easily see how to get H.
So this gives you a single first-order ODE. Since t doesn’t appear explicitly, it’s even separable, and you can write down an integral form for t(v); I don’t know if the general integral has a nice closed form.
The first of your geodesic equations is equivalent to
((R + r cos v)[sup]2[/sup] u’)’ = 0
which means that the quantity (R + r cos v)[sup]2[/sup] u’ is a constant along the geodesic. Call it C. In terms of C, your second geodesic equation then becomes
v’’ = - (r sin v) C[sup]2[/sup] / (r[sup]2[/sup] (R + r cos v)[sup]3[/sup] ).
This is in turn equivalent to
(v’)[sup]2[/sup] = D - C[sup]2[/sup] / (r[sup]2[/sup] (R + r cos v)[sup]2[/sup] )
where D is another constant (take the derivative of both sides to see this). This is a simple first-order ODE; however, I don’t know that it’s possible to solve it in closed form.
“Ray, for a moment, pretend that I don’t know anything about differential geometry, topology, or tensor calculus, and just tell me what the hell is going on.”
Seriously, thank all you guys for your help here. But I’m afraid it’s been about 14 years since I’ve solved a differential equation, and even then, I had no idea how to solve one as complicated as these. The fact of the matter is, I only yesterday learned how to calculate a Christoffel symbol by looking it up on Wikipedia. So, what I’m saying is, I lack the knowledge to calculate anything further. Except, of course, that a specific geodesic must have constants (u1,v1) and (u2,v2) to define the points it passes through. What’s next?
As far as I know there’s not a straightforward equation for what you want. The two equations you end up with, in the form MikeS gives, are
u’ = C / (R + r cos v)[sup]2[/sup]
(v’)[sup]2[/sup] = D - C[sup]2[/sup] / (r[sup]2[/sup] (R + r cos v)[sup]2[/sup] ) .
Because this is the differential-equation form for the geodesic, it only pays attention to the local curvature of the metric. This means that finding a geodesic between two given points (u[sub]1[/sub],v[sub]1[/sub]) and (u[sub]2[/sub],v[sub]2[/sub]) on the torus is not trivial. Much easier is to find a geodesic starting at a given point (u[sub]0[/sub],v[sub]0[/sub]) with a given initial velocity (u’[sub]0[/sub],v’[sub]0[/sub]).
Given an initial location and initial velocity, you can compute the integration constants C and D (just substitute the chosen initial values for u, v, u’, v’ in the two equations and solve for C and D). Then all you want is to integrate the resulting equations one more time. Unfortunately, these are probably hard equations to solve analytically; I haven’t tried, but just looking at them I’d guess that there’s no nice solution.
However, conceptually what this equation gives you is u’=du/dt and v’=dv/dt as functions of v, and this is all you need for a numerical solution. This lets you step along the curve by performing a numerical integration to find u and v, which is basically just a repetition of the following steps:[ol][li]compute v’(v)[]compute u’(v)[]recompute v = v + dtv’[]recompute u = u + dtu’[]recompute t = t + dt[/ol](Here dt is a time step for your numerical integration; the smaller the time step, the more accurate the result is likely to be. Try something like dt=0.01 to start with.) Each step through this loop gives you an estimate for a point (u,v) at time t along your chosen geodesic.[/li]
(This is about the simplest possible way to do a numerical integration; there are more sophisticated ways.)
Now if you want to find out the shortest path from (u[sub]0[/sub],v[sub]0[/sub]) to another point, you can iterate over these paths (varying the initial velocity (u’[sub]0[/sub],v’[sub]0[/sub])) to find one that gets close enough for your purposes. Probably you’d want to generate several geodesics at different initial angles from the starting point and pick the two that get closest, then iteratively converge on a solution to the starting angle.