plot::Function3d
-- graphical
primitive for a three-dimensional graph of a functionplot::Function3d
(f, x = a..b, y = c..d)
represents a plot of the function f(x,y) with (x,y) in
[a,b] x [c,d].
plot::Function3d(f, x = a..b, y = c..d <, option1,
option2...>)
f |
- | arithmetical expression in x and
y |
x, y |
- | identifiers |
a, b, c, d |
- | arithmetical expressions |
option1, option2, ... |
- | plot option(s) of the form OptionName =
value |
plot::Curve2d
,
plot::Function2d
,
plot::Surface3d
,
RGB
plot
, plot3d
, plotfunc3d
, plot::copy
plot::Function3d
represent
graphical primitives for two-dimensional graphs of functions that can
be displayed via plot(...)
, or used with other graphical
primitives of the plot
library.plotfunc3d
is also used to plot
three-dimensional graphs of functions. But in contrast to
plot::Function3d
, it does not return the graph in form of
a graphical object but displays the graph immediatly after executing
the command.
The main advantage of using plot::Function3d
is, that
you get the representation of the graph as an object. It can be
manipulated afterwards or combined easily with other graphical
primitives, such as polygons, curves or surfaces, to a common graphical
scene.
See example 2 below.
plot::Function3d
has type
"graphprim"
, i.e., if o
is such an object,
then the result of type(o)
is the string
"graphprim"
.option1
, option2
... 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] |
Grid | [ integer] |
[20,20] |
LineStyle | SolidLines, DashedLines | SolidLines |
LineWidth | positive integers | 1 |
PointStyle | Circles, FilledCircles, FilledSquares, Squares | FilledSquares |
PointWidth | positive integers | 30 |
Smoothness | [ integer] |
[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] |
||
Title | strings | |
TitlePosition | [x, y] |
|
plot3d
for further
details on each option.Scene options for the parameters
option1
, option2
... are not allowed! One may
pass scene options to the function plot
, or use plot::Scene
to create an object
representing a graphical scene. Cf. example 1.
::
.
Each attribute has the property ``read'', i.e., the value of an
attribute attr
of a graphical primitive o
can
be read with o::attr
. If the attribute also has the
``write'' property, then the value of the attribute can be changed with
o::attr := new_value
. See example 4.
The following attributes are available for a function primitive:
attribute | meaning | properties |
options |
A table of plot options of the function primitive.
Note that if you change the value of this attribute, the entries of the
assigned table are not checked to be valid plot options for function
primitives. Invalid entries lead to runtime errors.
The initial value of this attribute is the table stored under the
domain entry |
read/write |
plotdata |
List of the plot data of the function primitive in a
plot3d conforming
syntax (see the method "getPlotdata" below). Note that the
value of this attribute should only be used if the attribute
refreshPlotdata has the value FALSE (see
below). |
read |
range1 |
The first variable of the function and its range in
the form ident1 = a..b . The initial value is the parameter
x = a..b . |
read/write |
range2 |
The second variable of the function and its range in
the form ident2 = c..d . The initial value is the parameter
y = c..d . |
read/write |
refreshPlotdata |
A boolean value which signals whether the plot data of
the function primitive must be (re-)build with the method
"getPlotdata" (see below). If its value is
FALSE , then the plot data of the function primitive is
stored in the attribute plotdata . The initial value is
TRUE . See the help page of plot::Curve2d for an example. |
read/write |
term |
The term of the function. The initial value is the
parameter f . |
read/write |
An object of plot::Function3d
consists of three
operands. The first operand is the term f
of the graph.
The second operand is the first variable of the function and its range
in the form x = a..b
, and the third one is the second
variable of f
and its range in the form y =
c..d
.
Operands of a function primitive can be accessed either using the
system function op
, the
index operator [ ]
, or
using the attributes described above. For example, if
function
is such an object, then the calls
op(function,1)
, function[1]
and
function::term
return the expression f
.
Via function[1] := g
or function::term :=
g
, the term of a function plot can be changed to the value
g
.
See the methods "op"
, "_index"
,
"set_index"
and "slot"
below.
Use the slot operator ::
to get or set plot options of
such objects afterwards, i.e., when they have been created. For
example, if function
is such an object, then
function::Color := RGB::Red
changes the color of the
function primitive function
to red.
Evaluating an object of type plot::Function3d
returns
itself.
Calling an object of plot::Function3d
as a function
yields the object itself, regardless of the arguments. The arguments
are not evaluated.
is a table of plot options for function primitives and their default
values. Each entry has the form OptionName =
default_value
.
When an object of the domain plot::Function3d
is
created, then a copy of this table is stored under the attribute
options
(see the table of attributes above), where those
options are added and replaced, respectively, which are given by the
(optional) parameters option1
, option2
... of
the creating call (see ``Creating Elements'' above).
Plot options, which are not contained in the table stored under the
attribute options
will not be included in the plot data of
the object created by the method "getPlotdata"
(see
below).
For those options, the corresponding default value either is set by
a graphical scene, if the option also
exists as a scene option (such as the option PointWidth), or it is internally set by the function
plot3d
which is used to
plot the object. See the table of plot options above, which gives a
summary of the available plot options for function primitives and their
default values. See example 3.
To change the default value of some plot options, the option name
and its default value may be added to the table
"defaultOptions"
, or replaced by a new value,
respectively.
is a set of the available option names for plots of three-dimensional graphs of functions.
_index(dom function, positive integer i)
i
th operand of function
. See
``Operands'' above for a description of the operands of
function
. If i
is greater
than 3, then FAIL
is returned._index
, i.e., one may use it in the
form function[i]
, or in functional notation
_index(function, i)
.dimension(dom function)
getPlotdata(dom function)
function
in a plot3d
conforming syntax, i.e., it
has the form [Mode = Surface, [...], ...]
.
For example, with s :=
plot::Function3d::getPlotdata(function)
the call
plot3d(s[1])
gives a plot of function
.
options
(see the table of attributes above). For any other
plot option not contained in this table, the corresponding default
value set by the function plot3d
for surfaces is used when
plotting the object.plotdata
of function
.refreshPlotdata
of function
to
FALSE
.plot::Scene
to build the plot data of
the graphical scene.nops(dom function)
nops
, i.e., one may use it in the form
nops(function)
.op(dom function, positive
integer i)
i
th operand of function
. See
``Operands'' above for a description of the operands of
function
. If i
is greater
than 3, then FAIL
is returned.op
, i.e., one may use it in the form
op(function, i)
.set_index(dom function, positive integer i, any val)
i
th operand of function
by
the value val
. See ``Operands'' above for a description of
the operands of function
.i
is greater than 3, or if
val
is not an admissible value for the i
th
operand, then a warning message is issued. In this case the call of
this method has no effect on the object function
.refreshPlotdata
of function
to
TRUE
.slot(dom function, string slotname)
slotname
of
function
. slotname
may either be the name of
an attribute or the name of a plot option. See the tables of available
plot options and attributes above.slotname
is the name of a plot option, but the
option is not contained in the table stored under the attribute
options
, then FAIL
is returned.
If slotname
is an invalid attribute or option, then an
error message is issued.
slot
, i.e., one may use it in the form
function::slotname_id
(here, slotname_id
must
be the identifier corresponding to the string slotname
),
or in functional notation slot(function, slotname)
.slot(dom function, string slotname, any val)
slotname
to the value val
.slotname
, or if val
is not an admissible
value for slotname
, then a warning message is issued. In
this case, the value of slotname
remains unchanged.slot
, i.e., one may use it in the form
function::slotname_id := val
(here,
slotname_id
must be the identifier corresponding to the
string slotname
), or in functional notation
slot(function, slotname, val)
.refreshPlotdata
of
function
is set to TRUE
.checkOption(equation OptionName =
value)
OptionName
is a known plot
option for function primitives (see the table of available plot options
above), and value
is an admissible value for this
option.[TRUE, OptionName,
newValue]
is returned. Note that the value of the option could
have been converted into an admissible format. Thus,
newValue
must be used as the value of the option
OptionName
instead of value
.[FALSE, error_msg]
is returned.
The string error_msg
is a description of the located
problem, which can be passed, for example, to the system function
error
to raise a
user-specified exception.copy(dom function)
function
.plot::copy
. See its help page for
details.modify(dom function, equation(s) Name1 = value1...)
function
and changes the
slots Name1
... of this copy to the new values
value1
...Name1
... must be names of attributes
or plot options of the domain plot::Function3d
. Otherwise
a warning message is issued, and the slot remains unchanged. Also, if
one of the values value1
... is not an admissible value for
the corresponding attribute or plot option, respectively, the change of
the slot is ignored.
See the tables of available options and attributes above.
refreshPlotdata
of the copy of function
to
TRUE
.plot::modify
.print(dom function)
plot::Function3d(f, x = a..b, y = c..d)
. It is used to
print objects of plot::Function3d
to the screen.print
for details.The following call returns an object representing the graph of the function (x,y) -> sin(x*y) for x in [0, 2*PI] and y in [-PI, PI]:
>> f1 := plot::Function3d(sin(x*y), x = 0..2*PI, y = -PI..PI)
plot::Function3d(sin(x y), x = 0..2 PI, y = -PI..PI)
To plot this function in a graphical scene, call:
>> plot(f1)
Plot options of the surface can be given as additional parameters in the creating call, such as plotting the graph in blue color:
>> f2 := plot::Function3d(sin(x*y), x = 0..2*PI, y = -PI..PI, Color = [Flat, RGB::Blue])
plot::Function3d(sin(x y), x = 0..2 PI, y = -PI..PI)
>> plot(f2)
To change default values of some scene options, pass the
scene options to the call of plot
as additional arguments. For
example, to change the style of the axes:
>> plot(f1, Axes = Corner)
See the help page of plot::Scene
for available scene
options.
We want to display a graph of the function (x,y) -> sin(x) and the curve defined by t -> (t,sin(t),sin(t)). We start by creating the two different graphical primitives as follows:
>> f := plot::Function3d(sin(x), x = -PI..PI, y = -5..5); c := plot::Curve3d( [t, sin(t), sin(t)], t = -PI..PI, Color = RGB::Blue, LineWidth = 20 )
plot::Function3d(sin(x), x = -PI..PI, y = -5..5) plot::Curve3d([t, sin(t), sin(t)], t = -PI..PI)
To plot the scene of these objects, pass them as
parameters to the function plot
:
>> plot(f, c)
If a function primitive is created, values of some plot options of the created object can be read, or replaced by new values.
To illustrate this, we create the following function:
>> f := plot::Function3d(sin(x)*cos(y), x = 0..2*PI, y = 0..2*PI)
plot::Function3d(cos(y) sin(x), x = 0..2 PI, y = 0..2 PI)
and plot the graph:
>> plot(f)
The graph is drawn in color patches, together with the parameter lines of the two parameters of the surface. To change the style of the graph, use the option Style. For example, to display the graph as an opaque object together with the parameter lines, call:
>> f::Style:= [HiddenLine, Mesh]: plot(f)
and plot the graph:
>> plot(f)
The options that are set for an object are stored under
the attribute options
. You can read the value of this
attribute as follows:
>> f::options
table( Style = [HiddenLine, Mesh], Grid = [20, 20] )
If an option is not contained in this table, then its
value is set either by plot::Scene
, if the option also exists
as a scene option, or internally set by the function plot3d
when plotting the surface.
For example, the option Color is not contained in this table. If you try to read its value, you get the following result:
>> f::Color
FAIL
The default value of this option is the list [Height]
, set by the function plot3d
(see the table of options
above). The default colors are taken from the preferences of the
MuPAD's graphic tool VCam.
To override the default value of this option for the object
f
, enter:
>> f::Color:= [Flat, RGB::Red]: plot(f)
If we now take a look at the table stored under the
attribute options
, we get:
>> f::options
table( Color = [Flat, [1.0, 0.0, 0.0]], Style = [HiddenLine, Mesh], Grid = [20, 20] )
To delete some plot options set for a graphical primitive, call:
>> delete f::options[Style]: f::options
table( Color = [Flat, [1.0, 0.0, 0.0]], Grid = [20, 20] )
If we now plot the object f
, the default
value of the option Style is used, which is the
list [ColorPatches, AndMesh]
:
>> plot(f)
This example illustrates how to read and write attributes of function primitives (see the table of available attributes in ``Details'' above).
In the previous example we already introduced the attribute
options
. The attributes range1
and
range2
, for example, hold the ranges for the variables of
the function graph. We give an example:
>> f := plot::Function3d(x^2 + y^2, x = -5..5,y = -5..5)
2 2 plot::Function3d(x + y , x = -5..5, y = -5..5)
We can read the ranges of the variables:
>> f::range1, f::range2
x = -5..5, y = -5..5
Because these attributes have the ``write'' property, we can also change their values as follows:
>> f::range1:= x = -10..10: f::range2:= y = -10..10: plot(f)