Download MuPAD from SciFace

MuPAD Pro Computing Essentials - Examples 

Example 8.10 - Plotting solids

This is another example showing how complex geometry objects, here solids, can be modeled in MuPAD. I developed here a procedure  that will produce a pyramid and then I use this procedure to plot pyramids with different number of sides, height and radius of the base.

pyramid:=proc(r,height,n)
   local i, angle, topPoint, bottomPoint;
begin
   angle := 2*PI/n:
   topPoint := plot::Point([0,0,height]):
   bottomPoint := plot::Point([0,0,0]):
   
   base := plot::Polygon (
      bottomPoint,
      plot::Point(
         [r*cos(i*angle),r*sin(i*angle), 0]
      ),
      plot::Point(
         [r*cos((i+1)*angle),r*sin((i+1)*angle),0]
      ),
      Closed = TRUE,
      Filled = TRUE
   ) $ i=0..n-1:
   
   sides := plot::Polygon (
      topPoint,
      plot::Point(
         [r*cos(i*angle), r*sin(i*angle), 0]
      ),
      plot::Point(
         [r*cos((i+1)*angle),r*sin((i+1)*angle),0]
      ),
      Closed=TRUE,
      Filled=TRUE,
      Color=[i/n, 1-i/n, i/n]
   ) $ i=0..n-1:
   
   return(base, sides):
end:
 
Pyr := pyramid(3,5,12):
plot(Pyr, Scaling = Constrained, Axes = None)

    

 

TOP