Skip to Main Content Skip to Search
Product Documentation

plot::Spheregraphical primitive for spheres

plot::Ellipsoidgraphical primitive for ellipsoids

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

plot::Ellipsoid(r_x, r_y, r_z, c) creates an ellipsoid with the center c and symmetry axes parallel to the coordinate axes. The semi axes have the lengths rx, ry, rz.

→ Examples

Calls:

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

plot::Ellipsoid(rx, ry, rz, <[cx, cy, cz]>, <a = amin .. amax>, Options)

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.

rx, ry, rz

the length of the semi axes of the ellipsoid: real numerical values or arithmetical expressions of the animation parameter a
rx, ry, rz are equivalent to the attributes SemiAxes, SemiAxisX, SemiAxisY, SemiAxisZ.

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.

See Also:

plot, plot::Circle3d, plot::copy, plot::Surface

Details:

Ellipsoids with arbitrary orientations of the symmetry axes can be generated via plot::Rotate3d.

Example 1

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

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

plot::Sphere(3, [9, 9, 9])

Call plot to plot the sphere:

plot(s)

MuPAD graphics

Here is an ellipsoid around the origin with semi axes of lengths 1, 2, 3:

plot(plot::Ellipsoid(1, 2, 3, [0, 0, 0]))

MuPAD graphics

delete s:

Example 2

We create a sphere with center (-1, -1, 5) and radius 3. At two points on the sphere, we wish to 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 p[1] and p[2], respectively. The normals n[i] are given by p[i] - c. We compute them by subracting the center c from the points p[i] 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, we convert the points p[i] 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)

MuPAD graphics

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

Example 3

We consider the same sphere as in the previous example:

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

Using spherical coordinates, we 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, we define an animated point p that will run 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):

MuPAD graphicsimage

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

  


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