Previous Page Next Page Contents

plot::Function3d -- graphical primitive for a three-dimensional graph of a function

Introduction

plot::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].

Creating Elements

plot::Function3d(f, x = a..b, y = c..d <, option1, option2...>)

Parameters

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

Related Domains

plot::Curve2d, plot::Function2d, plot::Surface3d, RGB

Related Functions

plot, plot3d, plotfunc3d, plot::copy

Details

Operands

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.

Important Operations

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.

Result of Evaluation

Evaluating an object of type plot::Function3d returns itself.

Function Call

Calling an object of plot::Function3d as a function yields the object itself, regardless of the arguments. The arguments are not evaluated.

Entries

defaultOptions

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.

optionNames

is a set of the available option names for plots of three-dimensional graphs of functions.

Method _index: indexed access to the operands of a function primitive

Method dimension: dimension of a function primitive

Method getPlotdata: the plot data of a function primitive

Method nops: number of operands of a function primitive

Method op: extract operands of a function primitive

Method set_index: set operands of a function primitive

Method slot: read and write attributes and plot options

Method checkOption: check a plot option

Method copy: create a copy of a function primitive

Method modify: modify a copy of a function plot

Method print: print a function primitive

Example 1

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.

Example 2

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)

Example 3

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)

Example 4

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)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000