plot::Sphere

Graphical primitive for spheres

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

plot::Sphere(r, <[cx, cy, cz]>, <a = amin .. amax>, options)

Description

plot::Sphere(r, c) creates a sphere of radius r and center c.

Attributes

AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
Centercenter of objects, rotation center[0, 0, 0]
CenterXcenter of objects, rotation center, x-component0
CenterYcenter of objects, rotation center, y-component0
CenterZcenter of objects, rotation center, z-component0
Colorthe main colorRGB::LightBlue
FillColorcolor of areas and surfacesRGB::LightBlue
Framesthe number of frames in an animation50
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
Radiusradius of circles, spheres etc.1
Shadingsmooth color blend of surfacesSmooth
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
TitlePositionZposition of object titles, z component 
VisiblevisibilityTRUE
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE

Examples

Example 1

Create a blue sphere with center (9, 9, 9) and radius 3:

s := plot::Sphere(3, [9, 9, 9], Color = RGB::Blue)

Call plot to plot the sphere:

plot(s)

delete s:

Example 2

Create a sphere with center (- 1, - 1, 5) and radius 3. At two points on the sphere, add 3D discs indicating the tangent planes.

c := [-1, -1, 3]:
s := plot::Sphere(3, c):
p1 := [ 1, -3, 4]:
p2 := [-3, -2, 1]:

The discs are created via plot::Circle3d as filled 3D circles of radius 2.5, centered at the points p1 and p2, respectively. The normals ni are given by pi - c. Compute them by subracting the center c from the points pi via zip:

n1 := zip(p1, c, _subtract):
n2 := zip(p2, c, _subtract):
t1 := plot::Circle3d(2.5, p1, n1, Filled = TRUE, 
                     LineColor = RGB::Black,
                     FillColor = RGB::Red.[0.5]):
t2 := plot::Circle3d(2.5, p2, n2, Filled = TRUE, 
                     LineColor = RGB::Black,
                     FillColor = RGB::Red.[0.5]):

Finally, convert the points pi to graphical points and add them to the plot:

p1 := plot::Point3d(p1, PointColor = RGB::Red, 
                    PointSize = 2*unit::mm):
p2 := plot::Point3d(p2, PointColor = RGB::Red, 
                    PointSize = 2*unit::mm):
plot(s, p1, p2, t1, t2)

delete c, s, p1, p2, n1, n2, t1, t2:

Example 3

Consider the same sphere as in the previous example:

radius := 3: center := [-1, -1, 5]: 
s := plot::Sphere(radius, center):

Using spherical coordinates, define a curve on the sphere:

phi := a -> PI*sin(7*a):
thet := a -> PI/2 + 1.3*sin(5*a):
x := a -> center[1] + radius*cos(phi(a))*sin(thet(a)):
y := a -> center[2] + radius*sin(phi(a))*sin(thet(a)):
z := a -> center[3] + radius*cos(thet(a)):

The curve c is defined as an object of type plot::Curve3d. Further, define an animated point p that runs along the curve. An animated filled disc of type plot::Circle3d indicating the tangent plane at the point p as well as the corresponding normal are added to the plot:

c := plot::Curve3d([x(t), y(t), z(t)], t = 0..2*PI, 
                   Mesh = 1000, Color = RGB::Black):
p :=  a -> [x(a), y(a), z(a)]:
n :=  a -> zip([x(a), y(a), z(a)], center, _subtract):
d := plot::Circle3d(2.5, p(a), n(a), a = 0..2*PI, Filled = TRUE,
                    FillColor = RGB::BlueLight.[0.5],
                    LinesVisible = FALSE): 
n := plot::Arrow3d(p(a), [p(a)[i] + n(a)[i]/2 $ i=1..3], 
                   a = 0..2*PI, TipLength = 0.8*unit::mm):
p := plot::Point3d(p(a), a = 0..2*PI, PointColor = RGB::Black, 
                   PointSize = 2*unit::mm):
plot(s, c, p, n, d, Frames = 200, TimeEnd = 50):

delete radius, center, s, phi, thet,
       x, y, z, c, p, n, d:

Parameters

r

The radius of the sphere: a real numerical value or an arithmetical expression of the animation parameter a.

r is equivalent to the attribute Radius.

cx, cy, cz

The coordinates of the center: real numerical values or arithmetical expressions of the animation parameter a. If no center is specified, a sphere/ellipsoid centered at the orign is created.

cx, cy, cz are equivalent to the attributes Center, CenterX, CenterY, CenterZ.

a

Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

See Also

MuPAD Functions

MuPAD Graphical Primitives