Skip to Main Content Skip to Search
Product Documentation

plot::Sphericalsurfaces in 3D parameterized in spherical coordinates

plot::Spherical creates parametrized surfaces in 3D, with parametrization in spherical coordinates.

→ Examples

Call:

plot::Spherical([r, Symbol::phi, Symbol::theta], u = `u_{min}` .. `u_{max}`, v = `v_{min}` .. `v_{max}`, <a = amin .. amax>, Options)

Parameters:

r, Symbol::phi, Symbol::theta

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 real numerical value when the input parameters are numerical. 
r, Symbol::phi, Symbol::theta are equivalent to the attributes XFunction, YFunction, ZFunction.

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:

linalg::ogCoordTab, plot, plot::copy, plot::Cylindrical, plot::Polar, plot::Surface

Details:

Example 1

Spherical coordinates get their name from the fact that, with a constant radius, the parameterize a sphere:

plot(plot::Spherical([1, u, v], u = 0..2*PI, v = 0..PI))

MuPAD graphics

plot(plot::Spherical([1, u, v], u = 0..PI, v = 0..2*PI))

MuPAD graphics

Example 2

The following plot demonstrates that spherical plots can exhibit singular surface features even with differentiable parameterizations; in this case, the rim in the middle is actually a border of both the left- and the right-hand part:

plot(plot::Spherical(
       [(phi^2*thet), phi, thet^2],
       phi = -PI..PI, thet=0..0.25*PI,
       Mesh = [40,40], Submesh=[3,0],
       Color = [0.9$3], FillColorType=Flat, LineColor=[0.8$3]),
     Axes = None, CameraDirection = [1, 0, 0])

MuPAD graphics

Example 3

For oscillating parameterizations or other surfaces with fine details, the default mesh may be too coarse. As stated above, the three attributes Mesh, Submesh, and AdaptiveMesh can be used for improving plots of these objects.

First, note that the following plot is not rendered with a sufficient resolution:

surf := plot::Spherical([4+sin(5*(u+v)), u, v], u = 0..PI, v = 0..2*PI):
plot(surf, Axes = None)

MuPAD graphics

Setting Mesh to twice its default, we get a smoother surface with additional parameter lines:

surf::Mesh := [50, 50]:
plot(surf, Axes = None)

MuPAD graphics

Almost the same effect, but without the additional parameter lines, can be achieved by setting Submesh = [1, 1]:

delete surf::Mesh:
surf::Submesh := [1, 1]:
plot(surf, Axes = None)

MuPAD graphics

It is also possible to use adaptive mesh refinement in areas where neighboring patches have an angle of more than 10 degrees. While this option is mostly useful for surfaces which require refinement only in some parts, it is certainly feasible with a plot like this, too (but increasing Submesh is faster):

delete surf::Submesh:
surf::AdaptiveMesh := 2:
plot(surf, Axes = None)

MuPAD graphics

Example 4

The radius function r may also take on negative values. With radius functions of changing sign, spherical surfaces often do self-intersect:

plot(plot::Spherical(
       [sin(phi^2*thet), phi, thet],
         phi = -PI..PI, thet = 0..0.5*PI,
       Mesh = [40, 20], Submesh=[0, 3]))

MuPAD graphics

Example 5

The angular functions (Symbol::phi and Symbol::theta) are not limited in value:

plot(plot::Spherical([r, r, thet], r = 0..9, thet = -PI..PI,
                     Mesh = [60, 60], Filled = FALSE),
     Axes = None,
     plot::Camera([100, 100, 50], [0,0,0], 0.1))

MuPAD graphics

Note that we used an explicit plot::Camera object here because the automatic camera is always placed such that all of an object is visible, even when using CameraDirection. To get a “closer” look, use the interactive manipulation possibilities or an explicit camera.

Example 6

Singularities in the radius function are heuristically handled:

plot(plot::Spherical([1/(u + v), u, v], u = 0..PI, v = 0..PI))

MuPAD graphics

However, the heuristics fails for some examples:

plot(plot::Spherical([1/(u + v)^2, u, v], u = 0..PI, v = 0..PI))

MuPAD graphics

In cases like this, we recommend setting a viewing box explicitly with the attribute ViewingBox:

plot(plot::Spherical([1/(u + v)^2, u, v], u = 0..PI, v = 0..PI),
     ViewingBox = [-1/10..0.7, 0..1/4, -0.2..0.3])

MuPAD graphics

Example 7

By setting one of the parameter ranges to a degenerate interval, it is possible to draw curves on a spherical surface:

f := (u, v) -> [1 + u/10, u, v]:
surface := plot::Spherical(f(u,v), u = 0..2, v = 0..2,
                           FillColor = RGB::Grey, FillColorType = Flat):
curve := plot::Spherical(f((1 + sin(u)), (1 + sin(2*u))),
                         u = 0..2*PI, v = 0..0, Mesh = [200, 1],
                         LineColor = RGB::Red, LineWidth = 1):
plot(surface, curve)

MuPAD graphics

Example 8

While the transformation from spherical to Cartesian coordinates is not invertible, there are at least two ways of expressing each Cartesian point in spherical coordinates and any surface parameterizable in Cartesian coordinates can also be plotted using plot::Spherical (although this is probably more a curiosity than really useful):

trans := linalg::ogCoordTab[Spherical, InverseTransformation]:
spher := trans(x, y, sin(x^2+y^2))

[sqrt(x^2 + y^2 + sin(x^2 + y^2)^2), arccos(x/sqrt(x^2 + y^2)) + sign(y)*(sign(y) - 1)*(PI - arccos(x/sqrt(x^2 + y^2))), arccos(sin(x^2 + y^2)/sqrt(x^2 + y^2 + sin(x^2 + y^2)^2))]

plot(plot::Spherical(spher, x = -2..2, y = -2..2))

MuPAD graphics

Example 9

Last but not least we can also produce animations with the help of plot::Spherical. The following shows a deformation from a general spherical object to a sphere. We have used the animation parameter a inside of the argument for the sine function to obtain a slight rotation during the deformation process:

plot(
  plot::Spherical(
   [1+a*sin(3*Phi+a)*sin(2*Theta),Phi,Theta],
   Theta=0..PI, Phi=0..2*PI, a=5..0
  )
)

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