MATLAB: The length of the intersection curve between a sphere and a cylinder

line integral

How can I compute the length of the intersection curve between the sphere
x^2+y^2+z^2=16
and the cylinder
x^2+y^2=2x

Best Answer

I won't do your homework. I'll get you off to a good start, in fact, probably more than you deserve, since you appear to have made no serious effort.
The sphere is a sphere centered at the origin, of radius 4.
The cylinder is a circle in the (x,y) plane, so the same for all z. Completing the square, it can be written as:
(x^2 - 2*x +1) + y^2 = 1
or
(x - 1)^2 + y^2 = 1
So the cylinder has center (1,0,z), for all z.
That tells me the two objects do intersect, as well, they will intersect in TWO disjoint curves, one for positive z, the second for negative z.
In fact, if you view the intersection curve from the top, it will look perfectly circular. And this should be the clue you need.
Suppose you thought about this in terms of polar coordinates? To make it simple, translate the problem so the cylinder is centered at (0,0) in (x,y). Then the equation of the sphere is just:
(x+1)^2 + y^2 + z^2 == 16
The cylinder is now
x^2 + y^2 == 1
Nothing changes about the length of the curve. But perhaps now you can visualize that happens when we re-write this all in polar form. Actually, cylindrical coordiantes, thus (r,theta,z)
In cylindrical coordinates, the cylinder has equation
r == 1
Now, substitute into the sphere equation. Remember, since we now know that r==1,
x = r*cos(theta) = cos(theta)
y = r*sin(theta) = sin(theta)
now, lets look at what happened to the sphere.
(I've deleted the stuff that gives you a formula for z as a function of theta. In fact there is a remarkably simple form for z that will result.)
z = stufffffffffffff
Can you now find the arc length of that function, as theta varies from 0 to 2*pi? (I hope so.) A quick numerical computation of my own had the arc length as roughly 6.3864. My guess is only the first few digits of that are accurate, because of the approach I took for that first pass. But it should be close to 2*pi, but a bit larger, just as a visual assessment from a plot.
How do you find the arc length of a curve? I might be lazy, and use my arclength utility, as posted on the file exchange.
theta = linspace(0,2*pi,10000);
x = cos(theta);y = sin(theta);z = ????????;
arclength(x,y,z,'spline')
ans =
6.39448891369661
You should be able to do the same however, using an integration. A google search for the phrase
"arc length of a parametric curve"
might give you some ideas. Don't forget that this curve is in the form (x(theta),y(theta),z(theta)). x(theta) is just cos(theta), etc. In fact, when I do that computation, integral tells me the arc length should be
ans =
6.39448891369662
int did not find a symbolic solution however. Que sera, sera. But vpaintegral gives me:
ans =
6.3944889136966193144
I would note that the answer is indeed just a wee bit more than 2*pi, as I predicted it should be.
So, now all you need to do is do the algebra, then do some numerical methods work to replicate my results. IF you do decide to make a serious effort, then show what you did as a comment here. If you come at least close, showing that you have thought about the problem, then I might raise some of the veil on my answer.