| Contents | Index |
plot::Sphere(r, c) creates a sphere of radius r and center 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.
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. |
|
rx, ry, rz: |
the length of the semi axes of the ellipsoid: real numerical values or arithmetical expressions of the animation parameter a. |
|
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. |
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
and radius
:
s := plot::Sphere(3, [9, 9, 9], Color = RGB::Blue)
![]()
Call plot to plot the sphere:
plot(s)

Here is an ellipsoid around the origin with semi axes of lengths
,
,
:
plot(plot::Ellipsoid(1, 2, 3, [0, 0, 0]))

delete s:
Example 2
We create a sphere with center
and radius
. 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
, centered at the points
and
, respectively. The normals
are given by
. We compute them by subracting the center
from the points
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
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
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
is defined as an object of type plot::Curve3d. Further, we define an animated point
that will run along the curve. An animated filled disc of type plot::Circle3d indicating the tangent plane at the point
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:

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 |