plot3d
-- 3D plotsplot3d
(object1, object2, ...)
generates a
3D plot of graphical objects such as curves, surfaces, points, and
polygons.
plot3d( <SceneOptions,> object1, object2,
...)
object1, object2, ... |
- | graphical objects as described below |
SceneOptions |
- | a sequence of scene options. These determine the
general appearance of the graphical scene. See ?plotOptions3d for details. |
MuPAD's graphics tool is called to render the graphical
scene, and the null
()
object is returned
to the MuPAD session.
plot
, plotfunc2d
, plot2d
, plotfunc3d
plot3d
is a low level interface to create 3D plots
from graphical primitives. For graphs of functions, the specialized
routines plotfunc3d
and plot::Function3d
are more convenient. For graphical scenes built from primitives, we
recommend to use the plot
library, which provides various
primitives and tools. In most cases, the user will find it more
convenient to use the plot
library rather than
plot3d
.plot3d
: i) lists of graphical primitives (points and
polygons), ii) parametrized curves, and iii) parametrized
surfaces.[Mode = List,
[primitive1, primitive2, ...] <, Options>]
The available primitives are points, polygons and filled polygons
generated by the MuPAD functions point
and polygon
, respectively. You can use
such primitives to build more complicated graphical objects.
Options are specified by equations OptionName = value
.
The following table gives an overview of the available options:
OptionName |
admissible values | default value |
Color | [Flat] , [Flat, [r,g,b]] , [Height] , [Height, [r,g,b], [R,G,B]] , [Function, f] |
[Height] |
LineStyle | SolidLines, DashedLines | SolidLines |
LineWidth | positive integers | 1 |
PointStyle | Circles, FilledCircles, FilledSquares, Squares | FilledSquares |
PointWidth | positive integers | 30 |
Title | strings | |
TitlePosition | [x, y] |
|
plot3d
, a curve is
defined by an object of the following form:
[Mode=Curve,
[x(u),y(u),z(u)], u = [umin,umax] <, Options>]
The parametrization x(u)
, y(u)
,
z(u)
consists of arithmetical
expressions in one indeterminate u
(an identifier). They must not contain any other
symbolic parameters that cannot be converted to real floating point
numbers. The range of the curve parameter u
is given by
the real numbers or numerical expressions
umin
and umax
.
If the parametrization is given by user-defined functions that accept only numerical values, then
premature evaluation can be avoided using hold
(x)(u)
, hold
(y)(u)
, hold
(z)(u)
with the
symbolic curve parameter u
.
Options are specified by equations OptionName = value
.
All options for a list of primitives can be used. For curves, the
following additional options are available:
OptionName |
admissible values | default value |
Grid | [ integer] |
[100] |
Smoothness | [ integer] |
[0] |
Style | [Points] , [Lines] , [LinesPoints] , [Impulses] |
[Lines] |
plot3d
, a surface is defined by an object
of the following form:
[Mode = Surface, [x(u, v), y(u, v), z(u, v)], u = [umin, umax], v = [vmin, vmax] <, Options>]The parametrization
x(u,v)
, y(u,v)
,
z(u,v)
consists of arithmetical
expressions in two indeterminates u
, v
(identifiers). They must not contain any
other symbolic parameters that cannot be converted to real floating
point numbers. The ranges of the surface parameters u
and
v
are given by the real numbers or numerical expressions umin
,
umax
and vmin
, vmax
,
respectively.
If the parametrization is given by user-defined functions that accept only numerical values, then
premature evaluation can be avoided using hold
(x)(u,v)
, hold
(y)(u,v)
,
hold
(z)(u,v)
with the symbolic surface parameters u
,
v
.
Options are specified by equations OptionName = value
.
All options for a list of primitives can be used. For surfaces, the
following additional options are available:
OptionName |
admissible values | default value |
Grid | [ integer, integer] |
[20, 20] |
Smoothness | [ integer, integer] |
[0, 0] |
Style | [Points] |
[ColorPatches, |
[WireFrame, Mesh] |
AndMesh] |
|
[WireFrame, ULine] |
||
[WireFrame, VLine] |
||
[HiddenLine, Mesh] |
||
[HiddenLine, ULine] |
||
[HiddenLine, VLine] |
||
[ColorPatches, Only] |
||
[ColorPatches, AndMesh] |
||
[ColorPatches, AndULine] |
||
[ColorPatches, AndVLine] |
||
[Transparent, Only] |
||
[Transparent, AndMesh] |
||
[Transparent, AndULine] |
||
[Transparent, AndVLine] |
||
[Mode = Surface, [x, y, f(x, y)], x = [xmin, xmax], y = [ymin, ymax] <, Options>]:However, it is more convenient to use
plotfunc3d
or plot::Function3d
to plot or
generate function graphs.plot3d
command, the PlotDevice scene option allows to specify the conversion
into the two MuPAD specific formats 'Ascii' and 'Binary'. See the help
page plotOptions3d
for details.
For graphical standard formats such as Postscript, JPEG, TIFF etc., no direct conversion is available by a plot command inside a MuPAD session. Instead, conversion has to be requested interactively via the graphical interface of the rendering tool VCam. In a MuPAD Pro notebook, double click on the graphics to activate this interface. Using the menu item ``Edit/Save Graphics ..'', you can choose the desired format in the ``Export Graphics'' dialog box.
value
[Flat]
, [Flat, [r,g,b]]
, [Height]
, [Height,
[r,g,b], [R,G,B]]
and [Function,
f]
. The default is Color = [Height]
.
[Flat]
, the object is displayed with a flat color.
The actual color is chosen automatically.[Flat, [r, g, b]]
, the object is displayed with a
flat color. The values r
, g
, b
represent the red, green and blue contributions according to the RGB
color model. They must be real numbers between 0
and
1
. Pre-defined colors are provided by MuPAD's
RGB
data structure.[Height]
, the color varies with the
y-coordinate. The actual colors are chosen
automatically.[Height, [r, g, b], [R, G, B]]
, the color varies
with the y-coordinate. The parts of the object with small
values of y are displayed with the color [r, g,
b]
, parts with large values of y are displayed with
the color [R, G, B]
. Interpolated color values are used in
between.[Function, f]
, users may implement their own
coloring scheme. The parameter f
must be a MuPAD procedure returning a color as a list [r,
g, b]
.
f
must
accept three parameters:
f := proc(x, y, z) begin ..; return([r, g, b]) end:
During the numerical evaluation of the plot this function is called
with arguments (x, y, z)
from the viewing range of the
object.
Note that polygons are always displayed with a flat color.
f
must accept four
parameters:
f := proc(x, y, z, u) begin ..; return([r, g, b])
end:
During the numerical evaluation of the plot this function is called
with the arguments (x(u), y(u), z(u), u)
, where
u
is the curve parameter and x(u)
,
y(u)
, z(u)
are the corresponding
coordinates.
f
must accept
five parameters:
f := proc(x, y, z, u, v) begin ..; return([r, g, b])
end:
During the numerical evaluation of the plot this function is called
with the arguments (x(u,v), y(u,v), z(u,v), u, v)
, where
u
, v
are the curve parameters and
x(u,v)
, y(u,v)
, z(u,v)
are the
corresponding coordinates.
If the color function f
is created
inside a procedure, using local variables of this procedure, then this
procedure must use option
escape
.
[n]
(for curves)
n
must be larger than 1;
the default is Grid = [100]
. Large
values of n
generate a smooth curve. Alternatively, the Smoothness parameter can be increased.[nu, nv]
(for surfaces)
u
and v
.
The graphics uses linear interpolation between adjacent sample points.
The integers nu
, nv
must be larger than
1; the default is Grid = [20,
20]
. Large values of nu
, nv
generate a
smooth surface. Alternatively, the Smoothness
parameters can be increased.value
n
n
are nonnegative integers; the
default is LineWidth = 1.value
n
n
are positive integers; the default is PointWidth = 30.[n]
(for curves)
n
are integers between 0
and 20; the default is Smoothness =
[0]
. Lines are depicted as linear segments connecting
these interpolation points. Consequently, large values of
n
produce smooth lines.[nu, nv]
(for surfaces)
nu
, nv
are integers between 0
and 20; the default is Smoothness =
[0, 0]
. Large values of nu
, nv
generate a smooth surface.value
(for curves)
[Points]
,
[Lines]
, [LinesPoints]
and [Impulses]
. The default is Style = [Lines]
.
[Points]
, only the sample points determined by the
Grid option are displayed.[Lines]
, the curve is displayed as a collection of
line segments connecting the sample points.[LinesPoints]
, both the sample points as well as the
connecting line segments are displayed.[Impulses]
, the curve is displayed like a
``histogram'': vertical lines from the bottom of the scene to the
sample points are drawn.value
(for surfaces)
[ColorPatches, AndMesh]
.
[Points]
, only the sample points determined by the
Grid option are displayed.[WireFrame, Mesh]
, a wireframe
with the parameter lines of both surface parameters is displayed.[WireFrame, ULine]
, a
wireframe consisting of the parameter lines of the parameter
u
is displayed.[WireFrame, VLine]
, a
wireframe consisting of the parameter lines of the parameter
v
is displayed.[HiddenLine, Mesh]
, the
surface is displayed as an opaque object. Additionally, the parameter
lines of both parameters are displayed.[HiddenLine, ULine]
, the
surface is displayed as an opaque object. Additionally, the parameter
lines of the parameter u
are displayed.[HiddenLine, VLine]
, the
surface is displayed as an opaque object. Additionally, the parameter
lines of the parameter v
are displayed.[ColorPatches, Only]
, the
surface is displayed as an opaque object. All surface patches are
colored. No parameter lines are displayed.[ColorPatches, AndMesh]
, the
surface is displayed as an opaque object. All surface patches are
colored. Additionally, the parameter lines of both parameters are
displayed.[ColorPatches, AndULine]
, the
surface is displayed as an opaque object. All surface patches are
colored. Additionally, the parameter lines of the parameter
u
are displayed.[ColorPatches, AndVLine]
, the
surface is displayed as an opaque object. All surface patches are
colored. Additionally, the parameter lines of the parameter
v
are displayed.[Transparent, Only]
, the
surface patches are filled with patterns, simulating semi-transparency.
No parameter lines are displayed.[Transparent, AndMesh]
, the
surface patches are filled with patterns, simulating semi-transparency.
Additonally, the parameter lines of both parameters are displayed.[Transparent, AndULine]
, the
surface patches are filled with patterns, simulating semi-transparency.
Additionally, the parameter lines of the parameter u
are
displayed.[Transparent, AndVLine]
, the
surface patches are filled with patterns, simulating semi-transparency.
Additionally, the parameter lines of the parameter v
are
displayed.TitleString
TitleString
to the object. The default is the empty string
Title = , i.e., no title.[x, y]
x
, y
must be numerical values
between 0 and 10. The position [0,
0]
denotes the upper left corner of the scene, the position
[10, 10]
denotes the lower right corner.
Note that the specified positions are relative to the entire scene. Consequently, if titles are specified for several objects, their positions should differ to avoid overlap.
We demonstrate plotting of graphical primtives. First, three point primitives, a line primitive and a filled polygon is defined:
>> p1 := point(0, 0, 0, Color = RGB::Red): p2 := point(0, 1, 1/2, Color = RGB::Green): p3 := point(-1, 1, 1, Color = RGB::Blue): line := polygon(point(0, 0, 0), point(0, 1, 1/2), point(-1, 1, 1), Closed = TRUE, Color = RGB::Black): triangle := polygon(point(0, 0, 0), point(-1, 0.2, 0.4), point(-1, 1, 0), Closed = TRUE, Filled = TRUE, Color = RGB::Antique):
These are combined to a graphical object:
>> object := [Mode = List, [p1, p2, p3, line, triangle]]:
Finally, this object is plotted:
>> plot3d(BackGround = RGB::White, ForeGround = RGB::Black, PointWidth = 70, PointStyle = FilledCircles, Axes = Box, object)
>> delete p1, p2, p3, line, triangle, object:
We plot curves. The following picture demonstrates various styles:
>> plot3d(Axes = Box, Ticks = 0, BackGround = RGB::White, ForeGround = RGB::Black, [Mode = Curve, [u, -PI, cos(u)], u = [-PI, PI], Grid = [40], Style = [Points], PointWidth = 40 ], [Mode = Curve, [u, -PI/3, cos(u)], u = [-PI, PI], Grid = [40], Style = [Lines] ], [Mode = Curve, [u, PI/3, cos(u)], u = [-PI, PI], Grid = [40], Style = [LinesPoints], PointWidth = 30 ], [Mode = Curve, [u, PI, cos(u)], u = [-PI, PI], Grid = [40], Style = [Impulses] ]):
The following command plots a ``histogram style'' graph of the cosine function defined over the unit circle in the x-y-plane:
>> plot3d(Axes = Box, Ticks = 5, CameraPoint = [20, -10, 30], BackGround = RGB::White, ForeGround = RGB::Black, Labeling = TRUE, Labels = ["x", "y", "z"], Title = "A curve in space", [Mode = Curve, [cos(u), sin(u), sin(3*u)], u = [0, 2*PI], Grid = [200], Style = [Impulses] ])
The following command plots a spiral on the unit sphere:
>> plot3d(Axes = Box, Ticks = 0, Scaling = Constrained, Title = "spiral", TitlePosition = Below, [Mode = Curve, [cos(12*u*PI)*sin(u*PI), sin(12*u*PI)*sin(u*PI), cos(u*PI)], u = [0, 1], Grid = [50], Smoothness = [5] ])
We demonstrate surface plots. The next command generates spheres of radius 1 parametrized by polar coordinates. It illustrates various surface styles:
>> plot3d(Axes = Box, Ticks = 0, Scaling = Constrained, BackGround = RGB::White, ForeGround = RGB::Black, CameraPoint = [6, -21, 8], [Mode = Surface, [-2.5 + sin(u)*cos(v), sin(u)*sin(v), cos(u)], u = [0, PI], v = [0, 2*PI], Grid = [20, 20], Smoothness = [0, 0], Style = [HiddenLine, Mesh] ], [Mode = Surface, [sin(u)*cos(v), sin(u)*sin(v), cos(u)], u = [0, PI], v = [0, 2*PI], Grid = [15, 30], Smoothness = [0, 0], Style = [ColorPatches, AndULine] ], [Mode = Surface, [2.5 + sin(u)*cos(v), sin(u)*sin(v), cos(u)], u = [0, PI], v = [0, 2*PI], Grid = [10, 10], Smoothness = [0, 0], Style = [Transparent, AndVLine] ])
The effect of the options Grid and Smoothness is demonstrated by discs in the x-y-plane:
>> plot3d(Axes = None, Scaling = Constrained, BackGround = RGB::White, ForeGround = RGB::Black, CameraPoint = [0, -1, 20], [Mode = Surface, [-2.5 + v*sin(u), v*cos(u), 0], u = [-PI, PI], v = [0, 1], Style = [WireFrame, Mesh], Grid = [ 6, 6], Smoothness = [0, 0] ], [Mode = Surface, [v*sin(u), v*cos(u), 0], u = [-PI, PI], v = [0, 1], Style = [WireFrame, Mesh], Grid = [ 6, 6], Smoothness = [3, 2] ], [Mode = Surface, [2.5 + v*sin(u), v*cos(u), 0], u = [-PI, PI], v = [0, 1], Style = [WireFrame, Mesh], Grid = [20, 10], Smoothness = [0, 0] ])
The graph of a function is plotted as a parametrized surface:
>> plot3d(Axes = Box, Ticks = 8, BackGround = RGB::White, ForeGround = RGB::Black, Title = "Plot of sin(u^2 + v^2)", TitlePosition = Below, [Mode = Surface, [u, v, sin(u^2 + v^2)], u = [0, PI], v = [0, PI], Grid = [30, 30], Style = [HiddenLine, Mesh] ])
Various objects of different type are combined to a graphical scene:
>> plot3d(Axes = None, Scaling = Constrained, BackGround = RGB::White, ForeGround = RGB::Black, Title = "Three surfaces and a curve", TitlePosition = Below, CameraPoint = [13, -24, 20], [Mode = Surface, [(4 + cos(v))*cos(u), (4 + cos(v))*sin(u), sin(v)], u = [0, 2*PI], v = [0, 2*PI], Grid = [20, 20], Smoothness = [2, 0], Style = [HiddenLine, Mesh] ], [Mode = Surface, [2*cos(u)*sin(v), 2*sin(u)*sin(v), 2*cos(v)], u = [0, 2*PI], v = [0, PI], Grid = [10, 10], Smoothness = [2, 2], Style = [ColorPatches, AndMesh] ], [Mode = Surface, [u, v, -3], u = [-5, 5], v = [-5, 5], Grid = [5, 5], Smoothness = [0, 0], Style = [ColorPatches, Only] ], [Mode = Curve, [6*cos(12*u)*sin(u), 6*sin(12*u)*sin(u), 6*cos(u)], u = [0, PI], Grid = [50], Smoothness = [5], Title = "spiral" ])
We demonstrate user-defined color functions. The following function produces admissible RGB-values between 0 and 1 for objects with coordinates x,y,z in [-1,1]:
>> myColor := (x, y, z, u, v) -> [(abs(x) + 1)/2, abs(x - y)/(3 + z), abs(y)]:
A hyperboloid over the unit square is to be colored by the function above. We plot the graph of the function (x, y) -> x^2 - y^2 as a parametrized surface:
>> plot3d(Axes = Box, BackGround = RGB::White, ForeGround = RGB::Black, [Mode = Surface, [x, y, x^2 - y^2], x = [-1, 1], y = [-1, 1], Grid = [15, 15], Smoothness = [3, 3], Style = [ColorPatches, AndMesh], Color = [Function, myColor] ])
>> delete myColor: