var('u,v')
html("<h1>Solids of Revolution (x and y axis)</h1>")
html("<h2>Disk method</h2>")
@interact
def _(krivka=selector(["First Example (První příklad): 01a","Second Example (Druhý příklad): 01b","Third Example (Třetí příklad): 02c"], label="Curve (Křivka)", nrows=3, ncols=1, buttons=True),
rotace=slider(0,360, step_size=1, default=220, label="Rotation in Degrees (Rotace ve stupních)"),
):
pet=krivka[0:1]
if pet == "F":
f(x)=sqrt(3+x)
popisek="\sqrt{3+x}"
a=-1
b=3
elif pet == "S":
f(x)=sqrt((x-2)/(2*x+1))
popisek="\sqrt{(x-2)/(2x+1)}"
a=2
b=3
elif pet == "T":
f(x)=sqrt((2-x)/(3+2*x))
popisek="\sqrt{(2-x)/(3+2x)}"
a=1
b=2
horniv=rotace/360*2*pi
html("$y=f(x)=%s,\quad x\in<%s,%s>$"%(popisek,a,b))
"""
f(x)=sqrt(x)
a=1
b=4
f(x)=x
a=0
b=2
"""
Fx=f(x)
V=integral(pi*Fx^2,x,a,b)
derx=diff(Fx,x)
S=integral(2*pi*Fx*sqrt(1+derx^2),x,a,b)
print "\nFor full rotation...\n"
print "Vx =",V,"[units^3]"
print "Vx = %4.4f" % (V),"[units^3]\n"
print "Sx =",S,"[units^2]"
print "Sx = %4.4f" % (S),"[units^2]\n"
mycurve = plot(f(x),a,b,color="orange")
show(mycurve,aspect_ratio=1,figsize=3)
mypc=parametric_plot3d([u*cos(0),u*sin(0),f(u)],(u,a,b),color="orange",thickness=8)
mypb=parametric_plot3d([u*cos(v),u*sin(v),f(u)],(u,a,b),(v,0,2*pi),color="blue", opacity=0.05)
mysb=parametric_plot3d([u,sin(v)*f(u),cos(v)*f(u)],(u,a,b),(v,0,2*pi),color="green", opacity=0.05)
myp=parametric_plot3d([u*cos(v),u*sin(v),f(u)],(u,a,b),(v,0,horniv),color="blue")
mys=parametric_plot3d([u,sin(v)*f(u),cos(v)*f(u)],(u,a,b),(v,0,horniv),color="green")
show(mypb+mysb+myp+mys+mypc,aspect_ratio=1,figsize=5, viewer="jmol")