Barrel

Author

Eric W. Weisstein
February 10, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/SolidGeometry/Barrel.nb.

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

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

Code

addn[n_,k_,m_]:=Mod[n+k-1,m]+1
Barrel[f_,z_,{{r1_,rr1_},{r2_,rr2_}},{h_,hh_},{n_,nh_},opts___]:=Module[{i,j,a,caps,p},caps=Caps/.{opts}/.Options[Solids];
a=Table[{Cos[2.Pi i/n],Sin[2.Pi i/n]},{i,n}];
p=Table[Polygon[{Join[f a[[i]],{z}]/.z->j h/nh,Join[f a[[addn[i,1,n]]],{z}]/.z->j h/nh,Join[f a[[addn[i,1,n]]],{z}]/.z->(j+1) h/nh,Join[f a[[i]],{z}]/.z->(j+1) h/nh}/.{r1->rr1,r2->rr2,h->hh}],{j,0,nh-1},{i,n}];
If[caps,AppendTo[p,{Polygon[Table[Join[rr1 a[[i]],{0}],{i,n}]],Polygon[Table[Join[rr1 a[[i]],{hh}],{i,n}]]}]];
Graphics3D[p]]

Barrel::usage="Barrel.  The option Caps->True can be given."

Parabolic Cross-Section

x[z_]:=r2+(r1-r2)(h-2z)^2/h^2

x/@{0,h/2,h}

Simplify[Pi Integrate[x[z]^2,{z,0,h}]]

barrel=Show[Barrel[r2+(r1-r2)(h-2z)^2/h^2,z,{{r1,.7},{r2,1.}},{h,2.},{12,10},Caps->True],Boxed->False]

LiveGraphics3D

<<Utilities`LiveGraphics3D`

WriteLiveForm[barrelp.m,barrel]

Elliptical Cross-Section

x[z_]:= (Sqrt[r2^2+(((r1-r2) (r1+r2) (((h-2 z))^2))/(h^(2 )))])

PowerExpand[Simplify[x/@{0,h/2,h}]]

FullSimplify[Pi Integrate[x[z]^2,{z,0,h}]]

barrel=Show[Barrel[(Sqrt[r2^2+(((r1-r2) (r1+r2) (((h-2 z))^2))/((h^2) ))]),z,{{r1,.7},{r2,1.}},{h,2.},{12,10},Caps->True],Boxed->False]

LiveGraphics3D

WriteLiveForm["barrele.m",barrel]