## Wednesday, October 9, 2013

### Solid of revolution

# This program calculates the volume of a revolution solid.  The parameters  are hardcoded but they are highlighted for you to change
clg
font "arial", 15,100
graphsize 500,500
fastgraphics
#Graph Area######################
xmin=-6
xmax=6
ymin=-5
ymax=5
################################
tx=500/(xmax-xmin)
ty=500/(ymax-ymin)
area=0
#x Boudaries######################
bound1=-3
bound2=3
#################################
range=bound2-bound1
dx=.02
Volume_solid=0
for s = 0 to 2*pi step .1
if s <pi then
for y = ymin to ymax
for x = xmin to xmax
color black
circle tx*x-xmin*tx, ty*y-ymin*ty,3
if y=ymax+ymin then text tx*x-xmin*tx-15, ty*y-ymin*ty,x
if x=0 then text tx*x-xmin*tx-15,ty*y-ymin*ty,-y+ymax+ymin
next x : next y
line -xmin*tx,0,-xmin*tx,500 : line 0,500+ymin*ty,500,500+ymin*ty
end if
for x = xmin to xmax step dx
xg= tx*x-xmin*tx
color red
y0=y
#Equation###############################
y=sin(x)+2
########################################
yg1= 500-ty*y+ty*ymin
circle xg, yg1,1
#Solid
if x<= bound2 and  x>= bound1 then
fill= 100*(sin(s))+100
color rgb(200-fill,200-fill,fill)
arc xg-.05*y*ty*2, yg1, .1*y*ty*2, y*ty*2,s,.1
if s=0 then Volume_solid=Volume_solid+dx*(y0/2+y/2)^2*pi
#Area
if s <pi then
color green
if int(xg+1)/2 = int(xg/2+1) then line xg,yg1,xg,500+ymin*ty
fill= 255*(x-bound1)/range
end if
end if
next x
refresh
if s=0 then pause .5
pause .02
next s
input "press any key",k
Text 20,20, "Volume="+Volume_solid
refresh