Skip to Main Content Skip to Search
Product Documentation

plot::Surfaceparametrized surfaces in 3D

plot::Surface creates a parametrized surface in 3D.

→ Examples

Calls:

plot::Surface([x, y, z], u = `u_{min}` .. `u_{max}`, v = `v_{min}` .. `v_{max}`, <a = amin .. amax>, Options)

plot::Surface(xyz, u = `u_{min}` .. `u_{max}`, v = `v_{min}` .. `v_{max}`, <a = amin .. amax>, Options)

plot::Surface(A, u = `u_{min}` .. `u_{max}`, v = `v_{min}` .. `v_{max}`, <a = amin .. amax>, Options)

Parameters:

x, y, z

the coordinate functions: arithmetical expressions or piecewise objects depending on the surface parameters u, v and the animation parameter a. Alternatively, MuPAD procedures that accept 2 input parameters u, v or 3 input parameters u, v, a and return a numerical value when the input parameters are numerical. 
x, y, z are equivalent to the attributes XFunction, YFunction, ZFunction.

xyz

the parametrization: a MuPAD procedure that accepts 2 input parameters u, v or 3 input parameters u, v, a and returns a list of 3 numerical values [x, y, z].

A

a matrix of category Cat::Matrix with three entries that provide the parametrization x, y, z

u

the first surface parameter: an identifier or an indexed identifier
u is equivalent to the attribute UName.

`u_{min}` .. `u_{max}`

the plot range for the parameter u: `u_{min}`, `u_{max}` must be numerical real values or expressions of the animation parameter a
`u_{min}` .. `u_{max}` is equivalent to the attributes URange, UMin, UMax.

v

the second surface parameter: an identifier or an indexed identifier
v is equivalent to the attribute VName.

`v_{min}` .. `v_{max}`

the plot range for the parameter v: `v_{min}`, `v_{max}` must be numerical real values or expressions of the animation parameter a
`v_{min}` .. `v_{max}` is equivalent to the attributes VRange, VMin, VMax.

See Also:

plot, plot::copy, plot::Function3d, plot::Matrixplot, plotfunc3d

Details:

Example 1

Using standard spherical coordinates, a parametrization of a sphere of radius r by the azimuth angle u in [0, 2*PI] and the polar angle v in [0, PI] is given by:

x := r*cos(u)*sin(v):
y := r*sin(u)*sin(v):
z := r*cos(v):

We fix r = 1 and create the surface object:

r := 1:
s := plot::Surface([x, y, z], u = 0 .. 2*PI, v = 0 .. PI)

plot::Surface([cos(u)*sin(v), sin(u)*sin(v), cos(v)], u = 0..2*PI, v = 0..PI)

We call plot to plot the surface:

plot(s, Scaling = Constrained):

MuPAD graphics

delete x, y, z, r, s:

Example 2

The parametrization can also be specified by piecewise objects or procedures:

x := u*cos(v):
y := piecewise([u <= 1, u*sin(v)], [u >= 1, u^2*sin(v)]):
z := proc(u, v)
begin
  if u <= 1 then
     0
  else
     cos(4*v)
  end_if:
end_proc:
plot(plot::Surface([x, y, z], u = 0 .. sqrt(2), v = 0 .. 2*PI)):

MuPAD graphics

We enable adaptive sampling to get a smoother graphical result:

plot(plot::Surface([x, y, z], u = 0 .. sqrt(2), v = 0 .. 2*PI),
                   AdaptiveMesh = 3):

MuPAD graphics

delete x, y, z, s, r:

Example 3

We plot a surface with singularities:

s := plot::Surface([u*cos(v), u*sin(v), 1/u^2],
                   u = 0 .. 1, v = 0 .. 2*PI):
plot(s):

MuPAD graphics

We specify an explicit viewing range for the z coordinate:

plot(s, ViewingBox = [Automatic, Automatic, 0 .. 10]):

MuPAD graphics

delete s:

Example 4

By introducing non-real function evaluations, we can plot surfaces with holes:

chi := piecewise([sin(4*u) < cos(3*v)+0.5, 1]):
plot(plot::Surface([cos(u)*sin(v),
                    sin(u)*sin(v),
                    chi*cos(v)],
                   u = 0 .. 2*PI, v = 0 .. PI,
                   AdaptiveMesh=2), Scaling = Constrained)

MuPAD graphics

Example 5

We generate an animation of a surface of revolution. The graph of the function f(u) = 1/(1 + u^2) is rotated around the x-axis:

f :=  u -> 1/(1 + u^2):
plot(plot::Surface([u, f(u)*sin(v), f(u)*cos(v)], u = -2 .. 2,
                    v = 0 .. a*2*PI, a = 0 .. 1)):

MuPAD graphicsimage

See plot::XRotate, plot::ZRotate for an alternative way to create surfaces of revolution.

delete f:

Example 6

The standard mesh for the numerical evaluation of a surface does not suffice to generate a satisfying plot in the following case:

r := 2 + sin(7*u + 5*v):
x := r*cos(u)*sin(v):
y := r*sin(u)*sin(v):
z:=  r*cos(v):
plot(plot::Surface([x, y, z], u = 0 .. 2*PI, v = 0 .. PI)):

MuPAD graphics

We increase the number of mesh points. Here, we use USubmesh, VSubmesh to place 2 additional points in each direction between each pair of neighboring points of the default mesh. This increases the runtime for computing the plot by a factor of 9:

plot(plot::Surface([x, y, z], u = 0 .. 2*PI, v = 0 .. PI,
                   USubmesh = 2, VSubmesh = 2)):

MuPAD graphics

Alternatively, we enable adaptive sampling by setting the value of AdaptiveMesh to some positive value:

plot(plot::Surface([x, y, z], u = 0 .. 2*PI, v = 0 .. PI,
                   AdaptiveMesh = 2)):

MuPAD graphics

delete r, x, y, z:

Example 7

By default, the parameter lines of a parametrized surface are “switched on”:

x := r*cos(phi):
y := r*sin(phi):
z := r^2:
plot(plot::Surface([x, y, z], r = 1/3 .. 1, phi = 0 .. 2*PI)):

MuPAD graphics

The parameter lines are “switched off”:

plot(plot::Surface([x, y, z], r = 1/3 .. 1, phi = 0 .. 2*PI,
                   ULinesVisible = FALSE,
                   VLinesVisible = FALSE)):

MuPAD graphics

The number of parameter lines are determined by the attributes UMesh and VMesh:

plot(plot::Surface([x, y, z], r = 1/3 .. 1, phi = 0 .. 2*PI,
                   UMesh = 5, VMesh = 12)):

MuPAD graphics

When the mesh is refined via the attributes USubmesh, VSubmesh, the numerical approximation of the surface becomes smoother. However, the number of parameter lines is determined by the values of UMesh, VMesh and is not increased:

plot(plot::Surface([x, y, z], r = 1/3 .. 1, phi = 0 .. 2*PI,
                   UMesh = 5, VMesh = 12,
                   USubmesh = 1, VSubmesh = 2)):

MuPAD graphics

Example 8

Klein's bottle is a surface without orientation. There is no “inside” and no “outside” of the following object:

bx := u -> -6*cos(u)*(1 + sin(u)):
by := u -> -14*sin(u):
r :=  u -> 4 - 2*cos(u):
x := (u, v) -> piecewise([u <= PI, bx(u) - r(u)*cos(u)*cos(v)],
                         [PI < u,  bx(u) + r(u)*cos(v)]):
y := (u, v) -> r(u)*sin(v):
z := (u, v) -> piecewise([u <= PI, by(u) - r(u)*sin(u)*cos(v)],
                         [PI < u,  by(u)]):
KleinBottle:= plot::Surface(
      [x, y, z], u = 0 .. 2*PI, v = 0 .. 2*PI,
      Mesh = [35, 31], LineColor = RGB::Black.[0.2],
      FillColorFunction = RGB::MuPADGold):
plot(KleinBottle, Axes = None, Scaling = Constrained,
     Width = 60*unit::mm, Height = 72*unit::mm,
     BackgroundStyle = Pyramid):

MuPAD graphics

delete bx, by, r, x, y, z, KleinBottle:

Example 9

Finally we create an animated surface plot of (u, v) -> (sin(u), sin(v), a*sin(u + v)) where a is the animation parameter:

plot(
  plot::Surface(
   [sin(u),sin(v),a*sin(u+v)],
   u=0..2*PI, v=0..2*PI, a=1..0,
   AnimationStyle = BackAndForth
  )
)

MuPAD graphicsimage

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS