> # PLOTTING A SPHERE AND A CYLINDER Math II 18 Sept 96 # # # We plot a sphere using spherical coordinates, and a cylinder using # cylindrical coordinates. # # -------------------------------------------------------------------------------- # We need to use plots. > with(plots): -------------------------------------------------------------------------------- # # First get the cylinder. # cylinderplot can either be called in the form # cylinderplot(r,theta=a..b,z=c..d); # or in the form # cylinderplot([r(u,v),theta(u,v),z(u,v)],u=a..b,v=a..b); # We use the first form here. # > cylinderplot(1,theta=0..2*Pi,z=-3..3,color=red); > cyl := cylinderplot(1,theta=0..2*Pi,z=-3..3,color=red): -------------------------------------------------------------------------------- # # Now get the sphere. # sphereplot can either be called in the form # sphereplot(r,theta=a..b,phi=c..d); # or in the form # sphereplot([r(u,v),theta(u,v),phi(u,v)],u=a..b,v=c..d); # We use the first form here. # > sphereplot(2,theta=0..2*Pi,phi=0..Pi,color=blue); -------------------------------------------------------------------------------- # # We now take just part of the sphere > sph := sphereplot(2,theta=0..2*Pi,phi=Pi/6..5*Pi/6,color=blue): -------------------------------------------------------------------------------- # # Plot the cylinder and sphere on the same axes: # > display3d({cyl,sph},title=`Sphere and Cylinder`); -------------------------------------------------------------------------------- >