Capsule

Author

Eric W. Weisstein
June 4, 2015

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Surfaces/Capsule.nb.

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

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

Initialization

Capsule[h_:1,r_:1]:=(z-h/2)^2+x^2+y^2<=r^2||(z+h/2)^2+x^2+y^2<=r^2||(-h/2≤z<=h/2&&x^2+y^2<=r^2)

assum=h>0&&r>0;

vol=(1/3) π (r^2) (3 h+4 r);

Graphic

V5

<<Graphics`InequalityGraphics`

InequalityPlot3D[Capsule[],{x},{y},{z},Boxed->False,Axes->False]

V6

With[{r=1,h=1},Graphics3D[{Sphere[{0,0,-h/2},r],Sphere[{0,0,h/2},r],Cylinder[{{0,0,-h/2},{0,0,h/2}},r]},Boxed->False,Method->{"ShrinkWrap"->True},ImageSize->Small]]

Show[RegionPlot3D[Capsule[1,1],{x,-1,1},{y,-1,1},{z,-2,2},BoxRatios->Automatic,Boxed->False,Axes->False],Method->{"ShrinkWrap"->True},ImageSize->Small]

V10.2

$Version

DiscretizeGraphics@Graphics3D@With[{h=1,r=1},CapsuleShape[{{0,0,-h/2},{0,0,h/2}},r]]

Show[DiscretizeRegion@With[{h=1,r=1},CapsuleShape[{{0,0,-h/2},{0,0,h/2}},r]],Method->{"ShrinkWrap"->True},ImageSize->Small]

LiveGraphics3D

<<Utilities`LiveGraphics3D`

WriteLiveForm["capsule.m",%]

Properties

Centroid

Integrate

Assuming[assum,Integrate[{x,y,z}Boole[Capsule[h,r]],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞}]]//FullSimplify//Timing

RegionCentroid

Assuming[assum,RegionCentroid[CapsuleShape[{{0,0,-h/2},{0,0,h/2}},r]]//FullSimplify]//Timing

Convex

TimeConstrained[Region`ConvexRegionQ[EntityValue[Entity["Solid","SolidCapsule"],"ImplicitRegion"][h,r]],600]//Timing

TimeConstrained[Region`ConvexRegionQ[EntityValue[Entity["Solid","SolidCapsule"],"Region"][h,r]],600]//Timing

GeneralizedDiameter

Assuming[assum,Simplify[Max[h+2r,2r]]]

Assuming[assum,Simplify@Maximize[{
(x1-x2)^2+(y1-y2)^2+(z1-z2)^2,
assum&&
(Capsule[h,r]/.{x->x1,y->y1})&&(Capsule[h,r]/.{x->x2,y->y2})
},
{x1,y1,z1,x2,y2,z2}]]//Timing

FullSimplify[Sqrt[%[[2,1]]],assum]

InertiaTensor

InertiaMatrix[{x,y,z}]

(i=Assuming[assum,With[{ρ=(vol^(-1))},ρ Integrate[Boole[Capsule[h,r]]{{(y^2)+(z^2),-x y,-x z},{-x y,(x^2)+(z^2),-y z},{-x z,-y z,(x^2)+(y^2)}},{x,-∞,∞},{y,-∞,∞},{z,-∞,∞}]]//FullSimplify])//Timing

Limit[i,h->0]

MeanCylindricalRadius

Integrate Cartesian

Assuming[assum,FullSimplify[(vol^(-1))Integrate[(Sqrt[(x^2)+(y^2)])Boole[Capsule[h,r]],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞}]]]//Timing

Limit[,h->0]

MeanSphericalRadius

Integrate Cartesian

Assuming[assum,FullSimplify[(vol^(-1))Integrate[(Sqrt[(x^2)+(y^2)+(z^2)])Boole[Capsule[h,r]],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞}]]]//Timing

Limit[,h->0]

MeanSquareCylindricalRadius

Assuming[assum,FullSimplify[(vol^(-1))Integrate[((x^2)+(y^2))Boole[Capsule[h,r]],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞}]]]//Timing

Limit[(((r^2) (15 h+16 r))/(30 h+40 r)),h->0]

MeanSquareSphericalRadius

Assuming[assum,FullSimplify[(vol^(-1))Integrate[((x^2)+(y^2)+(z^2))Boole[Capsule[h,r]],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞}]]]//Timing

Limit[((5 (h^3)+20 (h^2) r+60 h (r^2)+48 (r^3))/(60 h+80 r)),h->0]

SurfaceArea

Assuming[assum,FullSimplify[4π (r^2)+2π r h]]

Volume

Integrate

Assuming[assum,Integrate[Boole[Capsule[h,r]],{x,-∞,∞},{y,-∞,∞},{z,-∞,∞}]]//FullSimplify//Timing

Assuming[assum,Integrate[Boole[Capsule[h,r]],{x,-r,r},{y,-r,r},{z,-(r+h/2),r+h/2}]]//FullSimplify//Timing

RegionMeasure

Assuming[assum,RegionMeasure[CapsuleShape[{{0,0,-h/2},{0,0,h/2}},r]]//FullSimplify]//Timing

Volume

Assuming[assum,Volume[CapsuleShape[{{0,0,-h/2},{0,0,h/2}},r]]//FullSimplify]//Timing