Cylinder-Sphere Intersection

Author

Eric W. Weisstein
August 31, 2005

This notebook downloaded from http://mathworld.wolfram.com/notebooks/SolidGeometry/Cylinder-SphereIntersection.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Cylinder-SphereIntersection.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<<Graphics`Shapes`

Equations

FullSimplify[Solve[{x^2+y^2+z^2==R^2,y^2+(z-(R-r))^2==r^2},{x,y}]]

x[z_,{r_,R_}]:=Sqrt[2(R-r)(R-z)];
y[z_,{r_,R_}]:=Sqrt[(R-z)(2r-R+z)];

Figure

Show[Graphics3D[{
Sphere[],
TranslateShape[
RotateShape[Cylinder[.25,1.5,15],0,Pi/2,Pi/2],{0,0,.5}
]}],Boxed->False]

Curve and Surface

polys[n_,{r_,R_}]:=Module[{z,dz=2r/n,i},Table[Polygon[{{-x[z,{r,R}],i y[z,{r,R}],z},{x[z,{r,R}],i y[z,{r,R}],z},{x[z+dz,{r,R}],i y[z+dz,{r,R}],z+dz},{-x[z+dz,{r,R}],i y[z+dz,{r,R}],z+dz}}],{z,R-2r,R-dz,dz},{i,-1,1,2}]]

wireframe=With[{r=.7,R=1,z1=.8,z2=.85},Show[Table[ParametricPlot3D[Evaluate[{i x[z,{r,R}],j y[z,{r,R}],z}],{z,R-2r,R},Axes->False,DisplayFunction->Identity],{i,-1,1,2},{j,-1,1,2}],DisplayFunction->$DisplayFunction]]

solid=With[{r=.7,R=1,z1=.8,z2=.85},Show[Graphics3D[polys[15,{r,R}]],DisplayFunction->$DisplayFunction,Boxed->False]]

Show[GraphicsArray[{wireframe,solid}]]

LiveGraphics3D

<<Utilities`LiveGraphics3D`

WriteLiveForm[cylsphw.m,wireframe]

WriteLiveForm[cylsphs.m,solid]

Surface Area

PowerExpand[FullSimplify[Sqrt[1+D[y[z,{r,R}],z]^2]]]

Integrate[Sqrt[2(R-r)(R-z)](r/Sqrt[(R-z)(2r-R+z)]),{z,R-2r,R}]

Integrate[r Sqrt[2(R-r)/(2r-R+z)],{z,R-2x,R}]

PowerExpand[Together//@PowerExpand[FullSimplify[%175]]]

Limit[%,x->r]

Volume

<<Graphics`InequalityGraphics`

Cylinder r internally tangent to sphere R

With[{R=1,r=.4},
Show[Graphics3D[{
InequalityPlot3D[x^2+y^2+z^2<R^2&&y^2+(z-(R-r))^2<r^2,{x},{y},{z},PlotPoints->15,DisplayFunction->Identity][[1]],
{Red,Wireframe[Sphere[]]}
}],ImageSize->200,Boxed->False]
]

v5.2

(vol=Integrate[Boole[x^2+y^2+z^2<R^2&&y^2+(z-(R-r))^2<r^2],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞},Assumptions->0<r<R])//Timing

...connection dies and cpu churns...

With[{R=1},(vol=Integrate[Boole[x^2+y^2+z^2<R^2&&y^2+(z-(R-r))^2<r^2],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞},Assumptions->0<r<R])
]//Timing

...crashes...

v6

(vol=Integrate[Boole[x^2+y^2+z^2<R^2&&y^2+(z-(R-r))^2<r^2],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞},Assumptions->0<r<R])//Timing

...crash...

With[{R=1},(vol=Integrate[Boole[x^2+y^2+z^2<R^2&&y^2+(z-(R-r))^2<r^2],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞},Assumptions->0<r<R])
]//Timing