Surface

SURFACE (FN f) [using] [color Ex RGBCOLOR] [in ST window name];

Use Surfacedomain, and Surfacerefinement

Creates an Implicit Surface or Parametric surface actor whose name is the name of the first variable: FN.  This actor is automatically placed as a named actor on the Display List. If you create a new surface (or graph) with the same name, it simply replaces the previous in the graph3D.

This command may be used in 3 ways:

In each case, you may set the domain and drawing refinement either with the Surfacedomain, and Surfacerefinement commands or directly from the Actors, create parametric surface menu. Once you create the actor with this command, you may define a script for it (say to change its color) in the Actor, Edit Script Menu. And you may save a collection of surfaces permanently to a scene file using the Save Scene File As... menu.

1) Draw a graph of a function of 2 variables.

This is the simplest and most direct way to draw graphs of functions of two variables. 

For example if given a real function of 2 variables: g(x,y), it can be graphed by executing:

surface g;

or (to draw it in light red)

draw the surface g using color gllred;

draw the surface g using color color(255,255,0,255);

By the way,

make h 2*g;

surface h;

has the desired effect, just as in graph2D windows.

2) create a parametric surface

If f is the name of a vector-valued function R2 --> R3, you may draw the parametric surface defined on the rectangle [s1,s2]x[t1,t2] with:

surface f;

Here, [s1,s2]x[t1,t2] is first established using the surfacedomain command, or from the Actors, create Parametric Surface Actor menu. Initially, the default is [-10,10]x[-10,10], otherwise the most recently used.

The surface is actually drawn as an approximating set of triangles. The mesh of that net of triangles is established with the surfacerefinement command, or from the Actors, create Parametric Surface Actor menu. Initially, the default is 8x8, otherwise the most recently used.

The following example creates a torus:

x(u,v,w)  := u;                           'define the projection functions'

y(u,v,w)  := v;

z(u,v,w)  := w;

cc(s) := [cos(s),  0, sin(s)];   'define the center circle of the torus'

make yy [0,1,0];                                   'define a constant upward-pointing vector'

tt(s,t) := 5*cc(s)+3*cc(s)*cos(t)+3*sin(t)*yy;              

'define the torus as parametric surface by revolving a second circle about the center circle.'

'Now define the component functions as compositions'

make c1 x#tt;

make c2 y#tt;

make c3 z#tt;

'Next, create the vector valued function of 2 variables:'

fun(s,t) := [c1(s,t),c2(s,t),c3(s,t)];

surfacedomain [-pi, pi], [-pi,pi];

surfacerefinement 50,20;

'This command creates and draws the torus whose name will be fun'

draw the surface fun;

or, to use the defaults, the simple command:

surface fun;

would do the trick.

3) create an implicit surface

An implicit surface is a surface in 3-space defined as the set of points that satisfy an equation of the form: f(x,y,z) = 0.

For example a "sphere" of radius 5 (the surface of a ball) may be defined as the set of points (x,y,z) such that

x^2 + y^2 + z^2 - 25 = 0 or such that x^2 + y^2 + z^2 = 25

You may define such a sphere if create a 1-vector valued function of 3 variables whose zero set is that surface, such as:

f(s,t,u) := [ s^2 + t^2 + u^2 - 25 ];

and then execute

surface f;

Another way to do this, is to use the Actors, Create Implicit Surface Actor menu item. In the dialog box, you may write such an equation in variables x,y, and z. If you write an expression instead of an equation such as: x^2 + y^2 + z^2 - 25 the system will assume that you intend to set it to zero, and replace with the equation (in this case) x^2 + y^2 + z^2 - 25 = 0.

The points that satisfy the equation in a certain "box" are drawn as the solution. The box is initially [-10,10]x[-10,10]x[-10,10] but you may change that in the dialog box of the Actors, Create Implicit Surface Actor menu.

Of course, the equations you use may be more interesting than this. For example, you may define any function of variables x,y,z and set it to zero. So if you typed:

f(x,y):=x*y;

g(x,y,z) := [f(x,y)+f(x,z)+f(y,z)-5];

surface g;

you would see the implicit surface defined by the equation f(x,y) +f(x,z)+f(y,z) = 5.

When you use this option, you actually create an Implicit Surface actor. This may be given a script (choosing for example a color for it) and it may be saved in a scene file as part of a scene.

When you define an equation in variables: x,y,z. The points in a "box" you select that satisfy the equation are drawn in the resolution from 2 -> 39 that you choose. If you choose resolution r, the original box is divided into r^3 sub-boxes to construct the surface. Also, the equation may be any MathScript equation, and so does not necessarily have to be algebraic. For example, if you define the program:

Program max3 (ex x) (ex y) (ex z) { if x > y then {let a be x} else {let a be y}; if a > z then {return a} else {return z}; }

An "implicit surface" may be drawn with equation: Max3(x,y,z) = 5 Only the points in the specified box are drawn. You may, for good resolution choose a very small box, and then rescale the actor, or move it closer to the camera.