7.1 Two-Dimensional Graphics
The Axiom two-dimensional graphics package provides the ability
to graphics:two-dimensional display
-
curves defined by functions of a single real variable
- curves defined by parametric equations
- implicit non-singular curves defined by polynomial equations
- planar graphs generated from lists of point components.
These graphs can be modified by specifying various options, such as
calculating points in the polar coordinate system or changing the size
of the graph viewport window.
7.1.1 Plotting Two-Dimensional Functions of One Variable
curve:one variable function The first kind of
two-dimensional graph is that of a curve defined by a function
over a finite interval of the axis.
The general format for drawing a function defined by a formula is:
draw(f(x), x = a..b, options)
where defines the range of , and where options
prescribes zero or more options as described in
ugGraphTwoDOptions . An
example of an option is An alternative
format involving functions and is also available.
A simple way to plot a function is to use a formula. The first
argument is the formula. For the second argument, write the name of
the independent variable (here, ), followed by an ``='', and the
range of values.
Display this formula over the range .
Axiom converts your formula to a compiled function so that the
results can be computed quickly and efficiently.
draw(sin(tan(x)) - tan(sin(x)),x = 0..6)
Once again the formula is converted to a compiled function before any
points were computed. If you want to graph the same function on
several intervals, it is a good idea to define the function first so
that the function has to be compiled only once.
This time we first define the function.
f(x) == (x-1)*(x-2)*(x-3)
Type: Void
To draw the function, the first argument is its name and the second is
just the range with no independent variable.
draw(f, 0..4)
7.1.2 Plotting Two-Dimensional Parametric Plane Curves
The second kind of two-dimensional graph is that of
parametric plane curve curves produced by parametric
equations. curve:parametric plane Let and
be formulas or two functions and as the parameter
ranges over an interval . The function curve takes the
two functions and as its parameters.
The general format for drawing a two-dimensional plane curve defined by
parametric formulas and is:
draw(curve(f(t), g(t)), t = a..b, options)
where defines the range of the independent variable , and
where options prescribes zero or more options as described in
ugGraphThreeDOptions . An
example of an option is
Here's an example:
Define a parametric curve using a range involving , Axiom's way
of saying . For parametric curves, Axiom
compiles two functions, one for each of the functions and .
draw(curve(sin(t)*sin(2*t)*sin(3*t), sin(4*t)*sin(5*t)*sin(6*t)), t = 0..2*%pi)
The title may be an arbitrary string and is an optional argument to
the draw command.
draw(curve(cos(t), sin(t)), t = 0..2*%pi)
If you plan on plotting , as ranges over
several intervals, you may want to define functions and first,
so that they need not be recompiled every time you create a new graph.
Here's an example:
As before, you can first define the functions you wish to draw.
f(t:DFLOAT):DFLOAT == sin(3*t/4)
Function declaration f : DoubleFloat -> DoubleFloat has been
added to workspace.
Type: Void
Axiom compiles them to map DoubleFloat values to DoubleFloat
values.
g(t:DFLOAT):DFLOAT == sin(t)
Function declaration f : DoubleFloat -> DoubleFloat has been added
to workspace.
Type: Void
Give to curve the names of the functions, then write the range
without the name of the independent variable.
draw(curve(f,g),0..%pi)
Here is another look at the same curve but over a different
range. Notice that and are not recompiled. Also note that
Axiom provides a default title based on the first function specified
in curve.
draw(curve(f,g),-4*%pi..4*%pi)
7.1.3 Plotting Plane Algebraic Curves
A third kind of two-dimensional graph is a non-singular
``solution curve'' curve:plane algebraic in a rectangular
region of the plane. A solution curve is a curve defined by a
polynomial equation . plane algebraic curve
Non-singular means that the curve is ``smooth'' in that it does not
cross itself or come to a point (cusp). Algebraically, this means
that for any point on the curve, that is, a point such that
, the partial derivatives
and
are not both zero.
curve:smooth curve:non-singular smooth curve
non-singular curve
The general format for drawing a non-singular solution curve given by
a polynomial of the form is:
draw(p(x,y) = 0, x, y, range == [a..b, c..d], options)
where the second and third arguments name the first and second
independent variables of . A range option is always given to
designate a bounding rectangular region of the plane
.
Zero or more additional options as described in
ugGraphTwoDOptions may be given.
We require that the polynomial has rational or integral coefficients.
Here is an algebraic curve example (``Cartesian ovals''):
Cartesian:ovals
p := ((x**2 + y**2 + 1) - 8*x)**2 - (8*(x**2 + y**2 + 1)-4*x-1)
|
Type: Polynomial Integer
The first argument is always expressed as an equation of the form
where is a polynomial.
draw(p = 0, x, y, range == [-1..11, -7..7])
7.1.4 Two-Dimensional Options
The draw commands take an optional list of options, such as title shown above. Each option is given by the syntax:
name == value.
Here is a list of the available options in the
order that they are described below.
adaptive | clip | unit |
clip | curveColor | range |
toScale | pointColor | coordinates |
The option turns adaptive plotting on or off.
adaptive plotting Adaptive plotting uses an algorithm that
traverses a graph and computes more points for those parts of the
graph with high curvature. The higher the curvature of a region is,
the more points the algorithm computes.
graphics:2D options:adaptive
The adaptive option is normally on. Here we turn it off.
draw(sin(1/x),x=-2*%pi..2*%pi, adaptive == false)
The clip option turns clipping on or off.
graphics:2D options:clipping
If on, large values are cut off according to
clipPointsDefaultclipPointsDefaultGraphicsDefaults.
draw(tan(x),x=-2*%pi..2*%pi, clip == true)
Option toScale does plotting to scale if true or uses the
entire viewport if false. The default can be determined using
drawToScaledrawToScaleGraphicsDefaults.
graphics:2D options:to scale
draw(sin(x),x=-%pi..%pi, toScale == true, unit == [1.0,1.0])
Option clip with a range sets point clipping of a graph within
the graphics:2D options:clip in a range ranges specified in
the list . clipping If only one range is
specified, clipping applies to the y-axis.
draw(sec(x),x=-2*%pi..2*%pi, clip == [-2*%pi..2*%pi,-%pi..%pi], unit == [1.0,1.0])
Option curveColor sets the color of the graph curves or lines to
be the graphics:2D options:curve color indicated palette color
curve:color (see ugGraphColor and
ugGraphColorPalette ).
color:curve
draw(sin(x),x=-%pi..%pi, curveColor == bright red())
Option pointColor sets the color of the graph points to the
indicated graphics:2D options:point color palette color (see
ugGraphColor and
ugGraphColorPalette ).
color:point
draw(sin(x),x=-%pi..%pi, pointColor == pastel yellow())
Option unit sets the intervals at which the axis units are
plotted graphics:2D options:set units according to the
indicated steps [ interval, interval].
draw(curve(9*sin(3*t/4),8*sin(t)), t = -4*%pi..4*%pi, unit == [2.0,1.0])
Option range sets the range of variables in a graph to be within
the ranges graphics:2D options:range for solving plane
algebraic curve plots.
draw(y**2 + y - (x**3 - x) = 0, x, y, range == [-2..2,-2..1], unit==[1.0,1.0])
A second example of a solution plot.
draw(x**2 + y**2 = 1, x, y, range == [-3/2..3/2,-3/2..3/2], unit==[0.5,0.5])
Option indicates the coordinate system in which the
graph graphics:2D options:coordinates is plotted. The default
is to use the Cartesian coordinate system.
Cartesian:coordinate system For more details, see
ugGraphCoord
or CoordinateSystems.
coordinate system:Cartesian
draw(curve(sin(5*t),t),t=0..2*%pi, coordinates == polar)
7.1.5 Color
The domain Color Color provides operations for
manipulating graphics:color colors in two-dimensional
graphs. color Colors are objects of Color. Each color
has a hue and a weight. hue Hues are represented
by integers that range from to the
numberOfHues()numberOfHues()Color, normally
graphics:color:number of hues . weight Weights
are floats and have the value by default.
- color (integer)
-
creates a color of hue integer and weight .
- hue (color)
-
returns the hue of color as an integer.
graphics:color:hue function
- red ()
-
blue(),
green(), and yellow()
graphics:color:primary color functions
create colors of that hue with weight .
- +
- returns the
color that results from additively combining the indicated
and .
Color addition is not commutative: changing the order of the arguments
produces different results.
- integer * color
-
changes the weight of color by integer
without affecting its hue.
graphics:color:multiply function
For example,
produces a color closer to yellow than to red.
Color multiplication is not associative: changing the order of grouping
color:multiplication
produces different results.
These functions can be used to change the point and curve colors
for two- and three-dimensional graphs.
Use the pointColor option for points.
draw(x**2,x=-1..1,pointColor == green())
Use the curveColor option for curves.
draw(x**2,x=-1..1,curveColor == color(13) + 2*blue())
7.1.6 Palette
graphics:palette
Domain Palette is the domain of shades of colors:
dark, dim, bright, pastel, and light,
designated by the integers through , respectively.
Palette
Colors are normally ``bright.''
Type: PositiveInteger
To change the shade of a color, apply the name of a shade to it.
color:shade
shade
myFavoriteColor := dark blue()
|
Type: Palette
The expression
returns the value of a shade of .
Type: PositiveInteger
The expression returns its hue.
Type: Color
Palettes can be used in specifying colors in two-dimensional graphs.
draw(x**2,x=-1..1,curveColor == dark blue())
7.1.7 Two-Dimensional Control-Panel
graphics:2D control-panel
Once you have created a viewport, move your mouse to the viewport and click
with your left mouse button to display a control-panel.
The panel is displayed on the side of the viewport closest to
where you clicked. Each of the buttons which toggle on and off show the
current state of the graph.
7.1.7.1 Transformations
graphics:2D control-panel:transformations
Object transformations are executed from the control-panel by mouse-activated
potentiometer windows.
- Scale:
- To scale a graph, click on a mouse button
graphics:2D control-panel:scale
within the Scale window in the upper left corner of the control-panel.
The axes along which the scaling is to occur are indicated by setting the
toggles above the arrow.
With X On and Y On appearing, both axes are selected and scaling
is uniform.
If either is not selected, for example, if X Off appears, scaling is
non-uniform.
- Translate:
- To translate a graph, click the mouse in the
graphics:2D control-panel:translate
Translate window in the direction you wish the graph to move.
This window is located in the upper right corner of the control-panel.
Along the top of the Translate window are two buttons for selecting
the direction of translation.
Translation along both coordinate axes results when X On and Y
On appear or along one axis when one is on, for example, X On and
Y Off appear.
7.1.7.2 Messages
graphics:2D control-panel:messages
The window directly below the transformation potentiometer windows is
used to display system messages relating to the viewport and the control-panel.
The following format is displayed:
[scaleX, scaleY] graph [translateX, translateY]
The two values to the left show the scale factor along the X and
Y coordinate axes. The two values to the right show the distance of
translation from the center in the X and Y directions. The number
in the center shows which graph in the viewport this data pertains to.
When multiple graphs exist in the same viewport,
the graph must be selected (see ``Multiple Graphs,'' below) in
order for its transformation data to be shown, otherwise the number
is 1.
7.1.7.3 Multiple Graphs
graphics:2D control-panel:multiple graphs
The Graphs window contains buttons that allow the placement
of two-dimensional graphs into one of nine available slots in any other
two-dimensional viewport.
In the center of the window are numeral buttons from one to nine
that show whether a graph is displayed in the viewport.
Below each number button is a button showing whether a graph
that is present is selected for application of some
transformation.
When the caret symbol is displayed, then the graph in that slot
will be manipulated.
Initially, the graph for which the viewport is created occupies
the first slot, is displayed, and is selected.
- Clear:
- The Clear button deselects every viewport graph slot.
graphics:2D control-panel:clear
A graph slot is reselected by selecting the button below its number.
- Query:
- The Query button is used to display the scale and
graphics:2D control-panel:query
translate data for the indicated graph. When this button is selected the
message ``Click on the graph to query'' appears. Select a slot
number button from the Graphs window. The scaling factor and translation
offset of the graph are then displayed in the message window.
- Pick:
- The Pick button is used to select a graph
graphics:2D control-panel:pick
to be placed or dropped into the indicated viewport. When this button is
selected, the message ``Click on the graph to pick'' appears.
Click on the slot with the graph number of the desired
graph. The graph information is held waiting for
you to execute a Drop in some other graph.
- Drop:
- Once a graph has been picked up using the Pick button,
graphics:2D control-panel:drop
the Drop button places it into a new viewport slot.
The message ``Click on the graph to drop'' appears in the message
window when the Drop button is selected.
By selecting one of the slot number buttons in the Graphs
window, the graph currently being held is dropped into this slot
and displayed.
7.1.7.4 Buttons
graphics:2D control-panel:buttons
- Axes
- turns the coordinate axes on or off.
graphics:2D control-panel:axes
- Units
- turns the units along the x
and y axis on or off.
graphics:2D control-panel:units
- Box
- encloses the area of the viewport graph
in a bounding box, or removes the box if already enclosed.
graphics:2D control-panel:box
- Pts
- turns on or off the display of points.
graphics:2D control-panel:points
- Lines
- turns on or off the display
of lines connecting points.
graphics:2D control-panel:lines
- PS
- writes the current viewport contents to
graphics:2D control-panel:ps
a file axiom2D.ps or to a name specified in the user's
graphics:.Xdefaults:PostScript file name
.Xdefaults file.
file:.Xdefaults @ .Xdefaults
The file is placed in the directory from which Axiom or the
viewAlone program was invoked.
PostScript
- Reset
- resets the object transformation
characteristics and attributes back to their initial states.
graphics:2D control-panel:reset
- Hide
- makes the control-panel disappear.
graphics:2D control-panel:hide
- Quit
- queries whether the current viewport
graphics:2D control-panel:quit
session should be terminated.
7.1.8 Operations for Two-Dimensional Graphics
Here is a summary of useful Axiom operations for two-dimensional
graphics.
Each operation name is followed by a list of arguments.
Each argument is written as a variable informally named according
to the type of the argument (for example, integer).
If appropriate, a default value for an argument is given in
parentheses immediately following the name.
- adaptive ([boolean(true)])
-
adaptive plotting
sets or indicates whether graphs are plotted
graphics:set 2D defaults:adaptive
according to the adaptive refinement algorithm.
- axesColorDefault ([color(dark blue())])
-
sets or indicates the default color of the
graphics:set 2D defaults:axes color
axes in a two-dimensional graph viewport.
- clipPointsDefault ([boolean(false)])
-
sets or
indicates whether point clipping is
graphics:set 2D defaults:clip points
to be applied as the default for graph plots.
- drawToScale ([boolean(false)])
-
sets or
indicates whether the plot of a graph
graphics:set 2D defaults:to scale
is ``to scale'' or uses the entire viewport space as the default.
- lineColorDefault ([color(pastel yellow())])
-
sets or indicates the default color of the
graphics:set 2D defaults:line color
lines or curves in a two-dimensional graph viewport.
- maxPoints ([integer(500)])
-
sets or indicates
the default maximum number of
graphics:set 2D defaults:max points
possible points to be used when constructing a two-dimensional graph.
- minPoints ([integer(21)])
-
sets or indicates the default minimum number of
graphics:set 2D defaults:min points
possible points to be used when constructing a two-dimensional graph.
- pointColorDefault ([color(bright red())])
-
sets or indicates the default color of the
graphics:set 2D defaults:point color
points in a two-dimensional graph viewport.
- pointSizeDefault ([integer(5)])
-
sets or indicates the default size of the
graphics:set 2D defaults:point size
dot used to plot points in a two-dimensional graph.
- screenResolution ([integer(600)])
-
sets or indicates the default screen
graphics:set 2D defaults:screen resolution
resolution constant used in setting the computation limit of adaptively
adaptive plotting
generated curve plots.
- unitsColorDefault ([color(dim green())])
-
sets or indicates the default color of the
graphics:set 2D defaults:units color
unit labels in a two-dimensional graph viewport.
- viewDefaults ()
-
resets the default settings for the following
graphics:set 2D defaults:reset viewport
attributes: point color, line color, axes color, units color, point size,
viewport upper left-hand corner position, and the viewport size.
- viewPosDefault ([list([100,100])])
-
sets or indicates the default position of the
graphics:set 2D defaults:viewport position
upper left-hand corner of a two-dimensional viewport, relative to the
display root window.
The upper left-hand corner of the display is considered to be at the
(0, 0) position.
- viewSizeDefault ([list([200,200])])
-
sets or
indicates the default size in which two
graphics:set 2D defaults:viewport size
dimensional viewport windows are shown.
It is defined by a width and then a height.
- viewWriteAvailable ([list(["pixmap","bitmap", "postscript", "image"])])
-
indicates the possible file types
graphics:2D defaults:available viewport writes
that can be created with the writewriteTwoDimensionalViewport function.
- viewWriteDefault ([list([])])
-
sets or indicates the default types of files, in
graphics:set 2D defaults:write viewport
addition to the data file, that are created when a
write function is executed on a viewport.
- units (viewport, integer(1), string("off"))
-
turns the units on or off for the graph with index integer.
- axes (viewport, integer(1), string("on"))
-
turns the axes on
graphics:2D commands:axes
or off for the graph with index integer.
- close (viewport)
-
closes viewport.
graphics:2D commands:close
- connect (viewport, integer(1), string("on"))
-
declares whether lines
graphics:2D commands:connect
connecting the points are displayed or not.
- controlPanel (viewport, string("off"))
-
declares
whether the two-dimensional control-panel is automatically displayed
or not.
- graphs (viewport)
-
returns a list
graphics:2D commands:graphs
describing the state of each graph.
If the graph state is not being used this is shown by "undefined",
otherwise a description of the graph's contents is shown.
- graphStates (viewport)
-
displays
graphics:2D commands:state of graphs
a list of all the graph states available for viewport, giving the
values for every property.
- key (viewport)
-
returns the process
graphics:2D commands:key
ID number for viewport.
- move (viewport,
(viewPosDefault),
(viewPosDefault))
-
moves viewport on the screen so that the
graphics:2D commands:move
upper left-hand corner of viewport is at the position (x,y).
- options (viewport)
-
returns a list
graphics:2D commands:options
of all the DrawOptions used by viewport.
- points (viewport, integer(1), string("on"))
-
specifies whether the graph points for graph integer are
graphics:2D commands:points
to be displayed or not.
- region (viewport, integer(1), string("off"))
-
declares whether graph integer is or is not to be displayed
with a bounding rectangle.
- reset (viewport)
-
resets all the properties of viewport.
- resize (viewport,
, )
-
graphics:2D commands:resize
resizes viewport with a new width and height.
- scale (viewport, (1),
(0.9), (0.9))
-
scales values for the
graphics:2D commands:scale
x and y coordinates of graph n.
- show (viewport, (1),
string("on"))
-
indicates if graph n is shown or not.
- title (viewport, string("Axiom 2D"))
-
designates the title for viewport.
- translate (viewport,
(1),
(0.0), (0.0))
-
graphics:2D commands:translate
causes graph n to be moved x and y units in the respective directions.
- write (viewport, ,
[strings])
-
if no third argument is given, writes the data file onto the directory
with extension data.
The third argument can be a single string or a list of strings with some or
all the entries "pixmap", "bitmap", "postscript", and
"image".
7.1.9 Addendum: Building Two-Dimensional Graphs
In this section we demonstrate how to create two-dimensional graphs from
lists of points and give an example showing how to read the lists
of points from a file.
7.1.9.1 Creating a Two-Dimensional Viewport from a List of Points
Axiom creates lists of points in a two-dimensional viewport by utilizing
the GraphImage and TwoDimensionalViewport domains.
In this example, the makeGraphImagemakeGraphImageGraphImage
function takes a list of lists of points parameter, a list of colors for
each point in the graph, a list of colors for each line in the graph, and
a list of sizes for each point in the graph.
The following expressions create a list of lists of points which will be read
by Axiom and made into a two-dimensional viewport.
p1 := point [1,1]$(Point DFLOAT)
Type: Point DoubleFloat
p2 := point [0,1]$(Point DFLOAT)
Type: Point DoubleFloat
p3 := point [0,0]$(Point DFLOAT)
Type: Point DoubleFloat
p4 := point [1,0]$(Point DFLOAT)
Type: Point DoubleFloat
p5 := point [1,.5]$(Point DFLOAT)
Type: Point DoubleFloat
p6 := point [.5,0]$(Point DFLOAT)
Type: Point DoubleFloat
p7 := point [0,0.5]$(Point DFLOAT)
Type: Point DoubleFloat
p8 := point [.5,1]$(Point DFLOAT)
Type: Point DoubleFloat
p9 := point [.25,.25]$(Point DFLOAT)
Type: Point DoubleFloat
p10 := point [.25,.75]$(Point DFLOAT)
Type: Point DoubleFloat
p11 := point [.75,.75]$(Point DFLOAT)
Type: Point DoubleFloat
p12 := point [.75,.25]$(Point DFLOAT)
Type: Point DoubleFloat
Finally, here is the list.
llp := [ [p1,p2], [p2,p3], [p3,p4], [p4,p1], [p5,p6], [p6,p7], [p7,p8], [p8,p5], [p9,p10], [p10,p11], [p11,p12], [p12,p9] ]
|
Type: List List Point DoubleFloat
Now we set the point sizes for all components of the graph.
size1 := 6::PositiveInteger
Type: PositiveInteger
size2 := 8::PositiveInteger
Type: PositiveInteger
size3 := 10::PositiveInteger
lsize := [size1, size1, size1, size1, size2, size2, size2, size2, size3, size3, size3, size3]
|
Type: List Polynomial Integer
Here are the colors for the points.
|
Type: Palette
|
Type: Palette
|
Type: Palette
lpc := [pc1, pc1, pc1, pc1, pc2, pc2, pc2, pc2, pc3, pc3, pc3, pc3]
|
Type: List Palette
Here are the colors for the lines.
lc := [pastel blue(), light yellow(), dim green(), bright red(), light green(), dim yellow(), bright blue(), dark red(), pastel red(), light blue(), dim green(), light yellow()]
|
Type: List Palette
Now the GraphImage is created according to the component
specifications indicated above.
g := makeGraphImage(llp,lpc,lc,lsize)$GRIMAGE
The makeViewport2DmakeViewport2DTwoDimensionalViewport function now
creates a TwoDimensionalViewport for this graph according to the
list of options specified within the brackets.
makeViewport2D(g,[title("Lines")])$VIEW2D
This example demonstrates the use of the GraphImage functions
componentcomponentGraphImage and appendPointappendPointGraphImage
in adding points to an empty GraphImage.
g := graphImage()$GRIMAGE
Type: GraphImage
p1 := point [0,0]$(Point DFLOAT)
Type: Point DoubleFloat
p2 := point [.25,.25]$(Point DFLOAT)
Type: Point DoubleFloat
p3 := point [.5,.5]$(Point DFLOAT)
Type: Point DoubleFloat
p4 := point [.75,.75]$(Point DFLOAT)
Type: Point DoubleFloat
p5 := point [1,1]$(Point DFLOAT)
Type: Point DoubleFloat
Type: Void
Type: Void
appendPoint(g,p3)$GRIMAGE
Type: Void
appendPoint(g,p4)$GRIMAGE
Type: Void
appendPoint(g,p5)$GRIMAGE
Type: Void
g1 := makeGraphImage(g)$GRIMAGE
Here is the graph.
makeViewport2D(g1,[title("Graph Points")])$VIEW2D
A list of points can also be made into a GraphImage by using
the operation coercecoerceGraphImage. It is equivalent to adding
each point to using componentcomponentGraphImage.
g2 := coerce([ [p1],[p2],[p3],[p4],[p5] ])$GRIMAGE
Now, create an empty TwoDimensionalViewport.
options(v,[title("Just Points")])$VIEW2D
Place the graph into the viewport.
Take a look.
makeViewport2D(v)$VIEW2D
7.1.9.2 Creating a Two-Dimensional Viewport of a List of Points from a File
The following three functions read a list of points from a
file and then draw the points and the connecting lines. The
points are stored in the file in readable form as floating point numbers
(specifically, DoubleFloat values) as an alternating
stream of - and -values. For example,
0.0 0.0 1.0 1.0 2.0 4.0
3.0 9.0 4.0 16.0 5.0 25.0
drawPoints(lp:List Point DoubleFloat):VIEW2D ==
g := graphImage()$GRIMAGE
for p in lp repeat
component(g,p,pointColorDefault(),lineColorDefault(),
pointSizeDefault())
gi := makeGraphImage(g)$GRIMAGE
makeViewport2D(gi,[title("Points")])$VIEW2D
drawLines(lp:List Point DoubleFloat):VIEW2D ==
g := graphImage()$GRIMAGE
component(g, lp, pointColorDefault(), lineColorDefault(),
pointSizeDefault())$GRIMAGE
gi := makeGraphImage(g)$GRIMAGE
makeViewport2D(gi,[title("Points")])$VIEW2D
plotData2D(name, title) ==
f:File(DFLOAT) := open(name,"input")
lp:LIST(Point DFLOAT) := empty()
while ((x := readIfCan!(f)) case DFLOAT) repeat
y : DFLOAT := read!(f)
lp := cons(point [x,y]$(Point DFLOAT), lp)
lp
close!(f)
drawPoints(lp)
drawLines(lp)
This command will actually create the viewport and the graph if
the point data is in the file .
plotData2D("file.data", "2D Data Plot")
7.1.10 Addendum: Appending a Graph to a Viewport Window Containing a Graph
This section demonstrates how to append a two-dimensional graph to a viewport
already containing other graphs.
The default draw command places a graph into the first
GraphImage slot position of the TwoDimensionalViewport.
This graph is in the first slot in its viewport.
v1 := draw(sin(x),x=0..2*%pi)
So is this graph.
v2 := draw(cos(x),x=0..2*%pi, curveColor==light red())
The operation getGraphgetGraphTwoDimensionalViewport
retrieves the GraphImage from the first slot position
in the viewport .
Now putGraphputGraphTwoDimensionalViewport
places into the the second slot position of .
Display the new TwoDimensionalViewport containing both graphs.
makeViewport2D(v2)
7.2 Three-Dimensional Graphics
The Axiom three-dimensional graphics package provides the ability to
graphics:three-dimensional
-
generate surfaces defined by a function of two real variables
- generate space curves and tubes defined by parametric equations
- generate surfaces defined by parametric equations
These graphs can be modified by using various options, such as calculating
points in the spherical coordinate system or changing the polygon grid size
of a surface.
7.2.1 Plotting Three-Dimensional Functions of Two Variables
surface:two variable function
The simplest three-dimensional graph is that of a surface defined by a function
of two variables, .
The general format for drawing a surface defined by a formula
of two variables and is:
draw(f(x,y), x = a..b, y = c..d, options)
where and define the range of
and , and where options prescribes zero or more
options as described in ugGraphThreeDOptions
.
An example of an option is
An alternative format involving a function is also
available.
The simplest way to plot a function of two variables is to use a formula.
With formulas you always precede the range specifications with
the variable name and an = sign.
draw(cos(x*y),x=-3..3,y=-3..3)
If you intend to use a function more than once,
or it is long and complex, then first
give its definition to Axiom.
Type: Void
To draw the function, just give its name and drop the variables
from the range specifications.
Axiom compiles your function for efficient computation
of data for the graph.
Notice that Axiom uses the text of your function as a
default title.
draw(f,-%pi..%pi,-%pi..%pi)
7.2.2 Plotting Three-Dimensional Parametric Space Curves
A second kind of three-dimensional graph is a three-dimensional space curve
curve:parametric space
defined by the parametric equations for , ,
parametric space curve
and as a function of an independent variable .
The general format for drawing a three-dimensional space curve defined by
parametric formulas , , and
is:
draw(curve(f(t),g(t),h(t)), t = a..b, options)
where defines the range of the independent variable
, and where options prescribes zero or more options
as described in ugGraphThreeDOptions
.
An example of an option is
An alternative format involving functions , and
is also available.
If you use explicit formulas to draw a space curve, always precede
the range specification with the variable name and an
= sign.
draw(curve(5*cos(t), 5*sin(t),t), t=-12..12)
Alternatively, you can draw space curves by referring to functions.
i1(t:DFLOAT):DFLOAT == sin(t)*cos(3*t/5)
Function declaration i1 : DoubleFloat -> DoubleFloat has been added
to workspace.
Type: Void
This is useful if the functions are to be used more than once ...
i2(t:DFLOAT):DFLOAT == cos(t)*cos(3*t/5)
Function declaration i2 : DoubleFloat -> DoubleFloat has been added
to workspace.
Type: Void
or if the functions are long and complex.
i3(t:DFLOAT):DFLOAT == cos(t)*sin(3*t/5)
Function declaration i3 : DoubleFloat -> DoubleFloat has been added
to workspace.
Type: Void
Give the names of the functions and
drop the variable name specification in the second argument.
Again, Axiom supplies a default title.
draw(curve(i1,i2,i3),0..15*%pi)
7.2.3 Plotting Three-Dimensional Parametric Surfaces
surface:parametric
A third kind of three-dimensional graph is a surface defined by
parametric surface
parametric equations for , , and
of two independent variables and .
The general format for drawing a three-dimensional graph defined by
parametric formulas , ,
and is:
draw(surface(f(u,v),g(u,v),h(u,v)), u = a..b, v = c..d, options)
where and define the range of the
independent variables and , and where
options prescribes zero or more options as described in
ugGraphThreeDOptions .
An example of an option is
An alternative format involving functions , and
is also available.
This example draws a graph of a surface plotted using the
parabolic cylindrical coordinate system option.
coordinate system:parabolic cylindrical
The values of the functions supplied to surface are
parabolic cylindrical coordinate system
interpreted in coordinates as given by a coordinates option,
here as parabolic cylindrical coordinates (see
ugGraphCoord ).
draw(surface(u*cos(v), u*sin(v), v*cos(u)), u=-4..4, v=0..%pi, coordinates== parabolicCylindrical)
Again, you can graph these parametric surfaces using functions,
if the functions are long and complex.
Here we declare the types of arguments and values to be of type
DoubleFloat.
n1(u:DFLOAT,v:DFLOAT):DFLOAT == u*cos(v)
Function declaration n1 : DoubleFloat -> DoubleFloat has been added
to workspace.
Type: Void
As shown by previous examples, these declarations are necessary.
n2(u:DFLOAT,v:DFLOAT):DFLOAT == u*sin(v)
Function declaration n2 : DoubleFloat -> DoubleFloat has been added
to workspace.
Type: Void
In either case, Axiom compiles the functions
when needed to graph a result.
n3(u:DFLOAT,v:DFLOAT):DFLOAT == u
Function declaration n3 : DoubleFloat -> DoubleFloat has been added
to workspace.
Type: Void
Without these declarations, you have to suffix floats
with to get a DoubleFloat result.
However, a call here with an unadorned float produces a DoubleFloat.
Compiling function n3 with type (DoubleFloat,DoubleFloat) ->
DoubleFloat
Type: DoubleFloat
Draw the surface by referencing the function names, this time
choosing the toroidal coordinate system.
coordinate system:toroidal
toroidal coordinate system
draw(surface(n1,n2,n3), 1..4, 1..2*%pi, coordinates == toroidal(1$DFLOAT))
7.2.4 Three-Dimensional Options
graphics:3D options
The draw commands optionally take an optional list of options such
as coordinates as shown in the last example.
Each option is given by the syntax: == .
Here is a list of the available options in the order that they are
described below:
title | coordinates | var1Steps |
style | tubeRadius | var2Steps |
colorFunction | tubePoints | space |
The option gives your graph a title.
graphics:3D options:title
draw(cos(x*y),x=0..2*%pi,y=0..%pi,title == "Title of Graph")
The determines which of four rendering algorithms is used for
rendering
the graph.
The choices are
"wireMesh", "solid", "shade", and "smooth".
draw(cos(x*y),x=-3..3,y=-3..3, style=="smooth", title=="Smooth Option")
In all but the wire-mesh style, polygons in a surface or tube plot
are normally colored in a graph according to their
-coordinate value. Space curves are colored according to their
parametric variable value.
graphics:3D options:color function
To change this, you can give a coloring function.
function:coloring
The coloring function is sampled across the range of its arguments, then
normalized onto the standard Axiom colormap.
A function of one variable makes the color depend on the
value of the parametric variable specified for a tube plot.
Type: Void
draw(curve(sin(t), cos(t),0), t=0..2*%pi, tubeRadius == .3, colorFunction == color1)
A function of two variables makes the color depend on the
values of the independent variables.
color2(u,v) == u**2 - v**2
Type: Void
Use the option colorFunction for special coloring.
draw(cos(u*v), u=-3..3, v=-3..3, colorFunction == color2)
With a three variable function, the
color also depends on the value of the function.
color3(x,y,fxy) == sin(x*fxy) + cos(y*fxy)
Type: Void
draw(cos(x*y), x=-3..3, y=-3..3, colorFunction == color3)
Normally the Cartesian coordinate system is used.
Cartesian:coordinate system
To change this, use the coordinates option.
coordinate system:Cartesian
For details, see ugGraphCoord .
m(u:DFLOAT,v:DFLOAT):DFLOAT == 1
Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
has been added to workspace.
Type: Void
Use the spherical
spherical coordinate system
coordinate system.
coordinate system:spherical
draw(m, 0..2*%pi,0..%pi, coordinates == spherical, style=="shade")
Space curves may be displayed as tubes with polygonal cross sections.
tube
Two options, tubeRadius and tubePoints, control the size and
shape of this cross section.
The tubeRadius option specifies the radius of the tube that
tube:radius
encircles the specified space curve.
draw(curve(sin(t),cos(t),0),t=0..2*%pi, style=="shade", tubeRadius == .3)
The tubePoints option specifies the number of vertices
tube:points in polygon
defining the polygon that is used to create a tube around the
specified space curve.
The larger this number is, the more cylindrical the tube becomes.
draw(curve(sin(t), cos(t), 0), t=0..2*%pi, style=="shade", tubeRadius == .25, tubePoints == 3)
graphics:3D options:variable steps
Options var1Stepsvar1StepsDrawOption and
var2Stepsvar2StepsDrawOption specify the number of intervals into
which the grid defining a surface plot is subdivided with respect to the
first and second parameters of the surface function(s).
draw(cos(x*y),x=-3..3,y=-3..3, style=="shade", var1Steps == 30, var2Steps == 30)
The space option
of a draw command lets you build multiple graphs in three space.
To use this option, first create an empty three-space object,
then use the space option thereafter.
There is no restriction as to the number or kinds
of graphs that can be combined this way.
Create an empty three-space object.
s := create3Space()$(ThreeSpace DFLOAT)
Type: ThreeSpace DoubleFloat
m(u:DFLOAT,v:DFLOAT):DFLOAT == 1
Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
has been added to workspace.
Type: Void
Add a graph to this three-space object.
The new graph destructively inserts the graph
into .
draw(m,0..%pi,0..2*%pi, coordinates == spherical, space == s)
Add a second graph to .
v := draw(curve(1.5*sin(t), 1.5*cos(t),0), t=0..2*%pi, tubeRadius == .25, space == s)
A three-space object can also be obtained from an existing three-dimensional viewport
using the subspacesubspaceThreeSpace command.
You can then use makeViewport3D to create a viewport window.
Assign to the three-space object in viewport .
Reset the space component of to the value of .
Create a viewport window from a three-space object.
makeViewport3D(subsp,"Graphs")
7.2.5 The makeObject Command
An alternate way to create multiple graphs is to use
makeObject.
The makeObject command is similar to the draw
command, except that it returns a three-space object rather than a
ThreeDimensionalViewport.
In fact, makeObject is called by the draw
command to create the ThreeSpace then
makeViewport3DmakeViewport3DThreeDimensionalViewport to create a
viewport window.
m(u:DFLOAT,v:DFLOAT):DFLOAT == 1
Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
has been added to workspace.
Type: Void
Do the last example a new way.
First use makeObject to
create a three-space object .
sph := makeObject(m, 0..%pi, 0..2*%pi, coordinates==spherical)
Compiling function m with type (DoubleFloat,DoubleFloat) ->
DoubleFloat
Type: ThreeSpace DoubleFloat
Add a second object to .
makeObject(curve(1.5*sin(t), 1.5*cos(t), 0), t=0..2*%pi, space == sph, tubeRadius == .25)
Compiling function %D with type DoubleFloat -> DoubleFloat
Compiling function %F with type DoubleFloat -> DoubleFloat
Compiling function %H with type DoubleFloat -> DoubleFloat
Type: ThreeSpace DoubleFloat
Create and display a viewport
containing .
makeViewport3D(sph,"Multiple Objects")
Note that an undefined ThreeSpace parameter declared in a
makeObject or draw command results in an error.
Use the create3Spacecreate3SpaceThreeSpace function to define a
ThreeSpace, or obtain a ThreeSpace that has been
previously generated before including it in a command line.
7.2.6 Building Three-Dimensional Objects From Primitives
Rather than using the draw and makeObject commands,
graphics:advanced:build 3D objects
you can create three-dimensional graphs from primitives.
Operation create3Spacecreate3SpaceThreeSpace creates a
three-space object to which points, curves and polygons
can be added using the operations from the ThreeSpace
domain.
The resulting object can then be displayed in a viewport using
makeViewport3DmakeViewport3DThreeDimensionalViewport.
Create the empty three-space object .
space := create3Space()$(ThreeSpace DFLOAT)
Type: ThreeSpace DoubleFloat
Objects can be sent to this using the operations
exported by the ThreeSpace domain.
ThreeSpace
The following examples place curves into .
Add these eight curves to the space.
closedCurve(space,[ [0,30,20], [0,30,30], [0,40,30], [0,40,100], [0,30,100],[0,30,110], [0,60,110], [0,60,100], [0,50,100], [0,50,30], [0,60,30], [0,60,20] ])
Type: ThreeSpace DoubleFloat
closedCurve(space,[ [80,0,30], [80,0,100], [70,0,110], [40,0,110], [30,0,100], [30,0,90], [40,0,90], [40,0,95], [45,0,100], [65,0,100], [70,0,95], [70,0,35] ])
Type: ThreeSpace DoubleFloat
closedCurve(space,[ [70,0,35], [65,0,30], [45,0,30], [40,0,35], [40,0,60], [50,0,60], [50,0,70], [30,0,70], [30,0,30], [40,0,20], [70,0,20], [80,0,30] ])
Type: ThreeSpace DoubleFloat
closedCurve(space,[ [0,70,20], [0,70,110], [0,110,110], [0,120,100], [0,120,70], [0,115,65], [0,120,60], [0,120,30], [0,110,20], [0,80,20], [0,80,30], [0,80,20] ])
Type: ThreeSpace DoubleFloat
closedCurve(space,[ [0,105,30], [0,110,35], [0,110,55], [0,105,60], [0,80,60], [0,80,70], [0,105,70], [0,110,75], [0,110,95], [0,105,100], [0,80,100], [0,80,20], [0,80,30] ])
Type: ThreeSpace DoubleFloat
closedCurve(space,[ [140,0,20], [140,0,110], [130,0,110], [90,0,20], [101,0,20],[114,0,50], [130,0,50], [130,0,60], [119,0,60], [130,0,85], [130,0,20] ])
Type: ThreeSpace DoubleFloat
closedCurve(space,[ [0,140,20], [0,140,110], [0,150,110], [0,170,50], [0,190,110], [0,200,110], [0,200,20], [0,190,20], [0,190,75], [0,175,35], [0,165,35],[0,150,75], [0,150,20] ])
Type: ThreeSpace DoubleFloat
closedCurve(space,[ [200,0,20], [200,0,110], [189,0,110], [160,0,45], [160,0,110], [150,0,110], [150,0,20], [161,0,20], [190,0,85], [190,0,20] ])
Type: ThreeSpace DoubleFloat
Create and display the viewport using makeViewport3D.
Options may also be given but here are displayed as a list with values
enclosed in parentheses.
makeViewport3D(space, title == "Letters")
7.2.6.1 Cube Example
As a second example of the use of primitives, we generate a cube using a
polygon mesh.
It is important to use a consistent orientation of the polygons for
correct generation of three-dimensional objects.
Again start with an empty three-space object.
spaceC := create3Space()$(ThreeSpace DFLOAT)
Type: ThreeSpace DoubleFloat
For convenience,
give DoubleFloat values and names.
Type: DoubleFloat
Type: DoubleFloat
Define the vertices of the cube.
a := point [x,x,y,1::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
b := point [y,x,y,4::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
c := point [y,x,x,8::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
d := point [x,x,x,12::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
e := point [x,y,y,16::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
f := point [y,y,y,20::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
g := point [y,y,x,24::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
h := point [x,y,x,27::DFLOAT]$(Point DFLOAT)
Type: Point DoubleFloat
Add the faces of the cube as polygons to the space using a
consistent orientation.
polygon(spaceC,[d,c,g,h])
Type: ThreeSpace DoubleFloat
polygon(spaceC,[d,h,e,a])
Type: ThreeSpace DoubleFloat
polygon(spaceC,[c,d,a,b])
Type: ThreeSpace DoubleFloat
polygon(spaceC,[g,c,b,f])
Type: ThreeSpace DoubleFloat
polygon(spaceC,[h,g,f,e])
Type: ThreeSpace DoubleFloat
polygon(spaceC,[e,f,b,a])
Type: ThreeSpace DoubleFloat
Create and display the viewport.
makeViewport3D(spaceC, title == "Cube")
7.2.7 Coordinate System Transformations
graphics:advanced:coordinate systems
The CoordinateSystems package provides coordinate transformation
functions that map a given data point from the coordinate system specified
into the Cartesian coordinate system.
CoordinateSystems
The default coordinate system, given a triplet , assumes
that , and ,
that is, reads the coordinates in order.
m(u:DFLOAT,v:DFLOAT):DFLOAT == u**2
Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
has been added to workspace.
Type: Void
Graph plotted in default coordinate system.
draw(m,0..3,0..5)
The coordinate comes first since the first argument of
the draw command gives its values.
In general, the coordinate systems Axiom provides, or any
that you make up, must provide a map to an triplet in
order to be compatible with the
coordinatescoordinatesDrawOption DrawOption.
DrawOption
Here is an example.
Define the identity function.
cartesian(point:Point DFLOAT):Point DFLOAT == point
Function declaration cartesian : Point DoubleFloat -> Point
DoubleFloat has been added to workspace.
Type: Void
Pass as the coordinatescoordinatesDrawOption
parameter to the draw command.
draw(m,0..3,0..5,coordinates==cartesian)
What happened? The option coordinates == cartesian directs
Axiom to treat the dependent variable defined by as the
coordinate. Thus the triplet of values is transformed
to coordinates and so we get the graph of .
Here is another example.
The cylindricalcylindricalCoordinateSystems transform takes
coordinate system:cylindrical
input of the form , interprets it in the order
cylindrical coordinate system
( , , )
and maps it to the Cartesian coordinates
, ,
in which
is the radius,
is the angle and
is the z-coordinate.
An example using the cylindricalcylindricalCoordinateSystems
coordinates for the constant .
f(u:DFLOAT,v:DFLOAT):DFLOAT == 3
Function declaration f : (DoubleFloat,DoubleFloat) -> DoubleFloat
has been added to workspace.
Type: Void
Graph plotted in cylindrical coordinates.
draw(f,0..%pi,0..6,coordinates==cylindrical)
Suppose you would like to specify as a function of
and instead of just ?
Well, you still can use the cylindrical Axiom
transformation but we have to reorder the triplet before
passing it to the transformation.
First, let's create a point to
work with and call it with some color .
Type: PositiveInteger
pt := point[1,2,3,col]$(Point DFLOAT)
Type: Point DoubleFloat
The reordering you want is
to
so that the first element is moved to the third element, while the second
and third elements move forward and the color element does not change.
Define a function reorder to reorder the point elements.
reorder(p:Point DFLOAT):Point DFLOAT == point[p.2, p.3, p.1, p.4]
Function declaration reorder : Point DoubleFloat -> Point
DoubleFloat has been added to workspace.
Type: Void
The function moves the second and third elements
forward but the color does not change.
Type: Point DoubleFloat
The function newmap converts our reordered version of
the cylindrical coordinate system to the standard
Cartesian system.
newmap(pt:Point DFLOAT):Point DFLOAT == cylindrical(reorder pt)
Function declaration newmap : Point DoubleFloat -> Point DoubleFloat
has been added to workspace.
Type: Void
|
Type: Point DoubleFloat
Graph the same function using the coordinate mapping of the function
, so it is now interpreted as
:
draw(f,0..3,0..2*%pi,coordinates==newmap)
The CoordinateSystems package exports the following
coordinate system
operations:
bipolar,
bipolarCylindrical,
cartesian,
conical,
cylindrical,
elliptic,
ellipticCylindrical,
oblateSpheroidal,
parabolic,
parabolicCylindrical,
paraboloidal,
polar,
prolateSpheroidal,
spherical, and
toroidal.
Use Browse or the )show system command
show
to get more information.
7.2.8 Three-Dimensional Clipping
A three-dimensional graph can be explicitly clipped within the draw
graphics:advanced:clip
command by indicating a minimum and maximum threshold for the
clipping
given function definition.
These thresholds can be defined using the Axiom min
and max functions.
gamma(x,y) ==
g := Gamma complex(x,y)
point [x, y, max( min(real g, 4), -4), argument g]
Here is an example that clips
the gamma function in order to eliminate the extreme divergence it creates.
draw(gamma,-%pi..%pi,-%pi..%pi,var1Steps==50,var2Steps==50)
7.2.9 Three-Dimensional Control-Panel
graphics:3D control-panel
Once you have created a viewport, move your mouse to the viewport
and click with your left mouse button.
This displays a control-panel on the side of the viewport
that is closest to where you clicked.
Three-dimensional control-panel.
7.2.9.1 Transformations
We recommend you first select the Bounds button while
graphics:3D control-panel:transformations
executing transformations since the bounding box displayed
indicates the object's position as it changes.
- Rotate:
- A rotation transformation occurs by clicking the mouse
graphics:3D control-panel:rotate
within the Rotate window in the upper left corner of the
control-panel.
The rotation is computed in spherical coordinates, using the
horizontal mouse position to increment or decrement the value of
the longitudinal angle within the
range of 0 to 2 and the vertical mouse position
to increment or decrement the value of the latitudinal angle
within the range of -
to .
The active mode of rotation is displayed in green on a color
monitor or in clear text on a black and white monitor, while the
inactive mode is displayed in red for color display or a mottled
pattern for black and white.
- origin:
- The origin button indicates that the
rotation is to occur with respect to the origin of the viewing space, that is
indicated by the axes.
- object:
- The object button indicates that the
rotation is to occur with respect to the center of volume of the object,
independent of the axes' origin position.
- Scale:
- A scaling transformation occurs by clicking the mouse
graphics:3D control-panel:scale
within the Scale window in the upper center of the
control-panel, containing a zoom arrow.
The axes along which the scaling is to occur are indicated by
selecting the appropriate button above the zoom arrow window.
The selected axes are displayed in green on a color monitor or in
clear text on a black and white monitor, while the unselected axes
are displayed in red for a color display or a mottled pattern for
black and white.
- uniform:
- Uniform scaling along the x, y
and z axes occurs when all the axes buttons are selected.
- non-uniform:
- If any of the axes buttons are
not selected, non-uniform scaling occurs, that is, scaling occurs only in the
direction of the axes that are selected.
- Translate:
- Translation occurs by indicating with the mouse in the
graphics:3D control-panel:translate
Translate window the direction you want the graph to move.
This window is located in the upper right corner of the
control-panel and contains a potentiometer with crossed arrows
pointing up, down, left and right.
Along the top of the Translate window are three buttons
( XY,
XZ, and YZ) indicating the three orthographic projection planes.
Each orientates the group as a view into that plane.
Any translation of the graph occurs only along this plane.
7.2.9.2 Messages
graphics:3D control-panel:messages
The window directly below the potentiometer windows for transformations is
used to display system messages relating to the viewport, the control-panel
and the current graph displaying status.
7.2.9.3 Colormap
graphics:3D control-panel:color map
Directly below the message window is the colormap range indicator
window.
colormap
The Axiom Colormap shows a sampling of the spectrum from
which hues can be drawn to represent the colors of a surface.
The Colormap is composed of five shades for each of the hues along
this spectrum.
By moving the markers above and below the Colormap, the range of
hues that are used to color the existing surface are set.
The bottom marker shows the hue for the low end of the color range
and the top marker shows the hue for the upper end of the range.
Setting the bottom and top markers at the same hue results in
monochromatic smooth shading of the graph when Smooth mode is selected.
At each end of the Colormap are + and - buttons.
When clicked on, these increment or decrement the top or bottom
marker.
7.2.9.4 Buttons
graphics:3D control-panel:buttons
Below the Colormap window and to the left are located various
buttons that determine the characteristics of a graph.
The buttons along the bottom and right hand side all have special
meanings; the remaining buttons in the first row indicate the mode
or style used to display the graph.
The second row are toggles that turn on or off a property of the
graph.
On a color monitor, the property is on if green (clear text, on a
monochrome monitor) and off if red (mottled pattern, on a
monochrome monitor).
Here is a list of their functions.
- Wire
- displays surface and tube plots as a
graphics:3D control-panel:wire
wireframe image in a single color (blue) with no hidden surfaces removed,
or displays space curve plots in colors based upon their parametric variables.
This is the fastest mode for displaying a graph.
This is very useful when you
want to find a good orientation of your graph.
- Solid
- displays the graph with hidden
graphics:3D control-panel:solid
surfaces removed, drawing each polygon beginning with the furthest
from the viewer.
The edges of the polygons are displayed in the hues specified by
the range in the Colormap window.
- Shade
- displays the graph with hidden
graphics:3D control-panel:shade
surfaces removed and with the polygons shaded, drawing each
polygon beginning with the furthest from the viewer.
Polygons are shaded in the hues specified by the range in the
Colormap window using the Phong illumination model.
Phong:illumination model
- Smooth
- displays the graph using a
graphics:3D control-panel:smooth
renderer that computes the graph one line at a time.
The location and color of the graph at each visible point on the
screen are determined and displayed using the Phong illumination
Phong:illumination model
model.
Smooth shading is done in one of two ways, depending on the range
selected in the colormap window and the number of colors available
from the hardware and/or window manager.
When the top and bottom markers of the colormap range are set to
different hues, the graph is rendered by dithering between the
dithering
transitions in color hue.
When the top and bottom markers of the colormap range are set to
the same hue, the graph is rendered using the Phong smooth shading
model.
Phong:smooth shading model
However, if enough colors cannot be allocated for this purpose,
the renderer reverts to the color dithering method until a
sufficient color supply is available.
For this reason, it may not be possible to render multiple Phong
smooth shaded graphs at the same time on some systems.
- Bounds
- encloses the entire volume of the
viewgraph within a bounding box, or removes the box if previously selected.
graphics:3D control-panel:bounds
The region that encloses the entire volume of the viewport graph is displayed.
- Axes
- displays Cartesian
graphics:3D control-panel:axes
coordinate axes of the space, or turns them off if previously selected.
- Outline
- causes
graphics:3D control-panel:outline
quadrilateral polygons forming the graph surface to be outlined in black when
the graph is displayed in Shade mode.
- BW
- converts a color viewport to black and white, or vice-versa.
graphics:3D control-panel:bw
When this button is selected the
control-panel and viewport switch to an immutable colormap composed of a range
of grey scale patterns or tiles that are used wherever shading is necessary.
- Light
- takes you to a control-panel described below.
- ViewVolume
- takes you to another control-panel as described below.
graphics:3D control-panel:save
- Save
- creates a menu of the possible file types that can
be written using the control-panel.
The Exit button leaves the save menu.
The Pixmap button writes an Axiom pixmap of
graphics:3D control-panel:pixmap
the current viewport contents. The file is called axiom3D.pixmap and is
located in the directory from which Axiom or viewAlone was
started.
The PS button writes the current viewport contents to
graphics:3D control-panel:ps
PostScript output rather than to the viewport window.
By default the file is called axiom3D.ps; however, if a file
file:.Xdefaults @ .Xdefaults
name is specified in the user's .Xdefaults file it is
graphics:.Xdefaults:PostScript file name
used.
The file is placed in the directory from which the Axiom or
viewAlone session was begun.
See also the writewriteThreeDimensionalViewport
function.
PostScript
- Reset
- returns the object transformation
graphics:3D control-panel:reset
characteristics back to their initial states.
- Hide
- causes the control-panel for the
graphics:3D control-panel:hide
corresponding viewport to disappear from the screen.
- Quit
- queries whether the current viewport
graphics:3D control-panel:quit
session should be terminated.
7.2.9.5 Light
graphics:3D control-panel:light
The Light button changes the control-panel into the
Lighting Control-Panel. At the top of this panel, the three axes
are shown with the same orientation as the object. A light vector from
the origin of the axes shows the current position of the light source
relative to the object. At the bottom of the panel is an Abort
button that cancels any changes to the lighting that were made, and a
Return button that carries out the current set of lighting changes
on the graph.
- XY:
- The XY lighting axes window is below the
graphics:3D control-panel:move xy
Lighting Control-Panel title and to the left.
This changes the light vector within the XY view plane.
- Z:
- The Z lighting axis window is below the
graphics:3D control-panel:move z
Lighting Control-Panel title and in the center. This
changes the Z
location of the light vector.
- Intensity:
-
Below the Lighting Control-Panel title
graphics:3D control-panel:intensity
and to the right is the light intensity meter.
Moving the intensity indicator down decreases the amount of
light emitted from the light source.
When the indicator is at the top of the meter the light source is
emitting at 100% intensity.
At the bottom of the meter the light source is emitting at a level
slightly above ambient lighting.
7.2.9.6 View Volume
graphics:3D control-panel:view volume
The View Volume button changes the control-panel into
the Viewing Volume Panel.
At the bottom of the viewing panel is an Abort button that
cancels any changes to the viewing volume that were made and a
Return button that carries out the current set of
viewing changes to the graph.
- Eye Reference:
- At the top of this panel is the
graphics:3D control-panel:eye reference
Eye Reference window.
It shows a planar projection of the viewing pyramid from the eye
of the viewer relative to the location of the object.
This has a bounding region represented by the rectangle on the
left.
Below the object rectangle is the Hither window.
By moving the slider in this window the hither clipping plane sets
hither clipping plane
the front of the view volume.
As a result of this depth clipping all points of the object closer
to the eye than this hither plane are not shown.
The Eye Distance slider to the right of the Hither
slider is used to change the degree of perspective in the image.
- Clip Volume:
- The Clip Volume window is at the
graphics:3D control-panel:clip volume
bottom of the Viewing Volume Panel.
On the right is a Settings menu.
In this menu are buttons to select viewing attributes.
Selecting the Perspective button computes the image using
perspective projection.
graphics:3D control-panel:perspective
The Show Region button indicates whether the clipping region
of the
graphics:3D control-panel:show clip region
volume is to be drawn in the viewport and the Clipping On
button shows whether the view volume clipping is to be in effect
when the image
graphics:3D control-panel:clipping on
is drawn.
The left side of the Clip Volume window shows the clipping
graphics:3D control-panel:clip volume
boundary of the graph.
Moving the knobs along the X, Y, and Z sliders
adjusts the volume of the clipping region accordingly.
7.2.10 Operations for Three-Dimensional Graphics
Here is a summary of useful Axiom operations for three-dimensional
graphics.
Each operation name is followed by a list of arguments.
Each argument is written as a variable informally named according
to the type of the argument (for example, integer).
If appropriate, a default value for an argument is given in
parentheses immediately following the name.
- adaptive3D? ()
-
tests whether space curves are to be plotted
graphics:plot3d defaults:adaptive
according to the
adaptive plotting
adaptive refinement algorithm.
- axes (viewport, string("on"))
-
turns the axes on and off.
graphics:3D commands:axes
- close (viewport)
-
closes the viewport.
graphics:3D commands:close
- colorDef (viewport,
(1), (27))
-
sets the colormap
graphics:3D commands:define color
range to be from
to .
- controlPanel (viewport, string("off"))
-
declares whether the
graphics:3D commands:control-panel
control-panel for the viewport is to be displayed or not.
- diagonals (viewport, string("off"))
-
declares whether the
graphics:3D commands:diagonals
polygon outline includes the diagonals or not.
- drawStyle (viewport, style)
-
selects which of four drawing styles
graphics:3D commands:drawing style
are used: "wireMesh", "solid", "shade", or "smooth".
- eyeDistance (viewport,float(500))
-
sets the distance of the eye from the origin of the object
graphics:3D commands:eye distance
for use in the perspectiveperspectiveThreeDimensionalViewport.
- key (viewport)
-
returns the operating
graphics:3D commands:key
system process ID number for the viewport.
- lighting (viewport,
(-0.5),
(0.5), (0.5))
-
sets the Cartesian
graphics:3D commands:lighting
coordinates of the light source.
- modifyPointData (viewport,integer,point)
-
replaces the coordinates of the point with
graphics:3D commands:modify point data
the index integer with point.
- move (viewport,
(viewPosDefault),
(viewPosDefault))
-
moves the upper
graphics:3D commands:move
left-hand corner of the viewport to screen position
({ , }).
- options (viewport)
-
returns a list of all current draw options.
- outlineRender (viewport, string("off"))
-
turns polygon outlining
graphics:3D commands:outline
off or on when drawing in "shade" mode.
- perspective (viewport, string("on"))
-
turns perspective
graphics:3D commands:perspective
viewing on and off.
- reset (viewport)
-
resets the attributes of a viewport to their
graphics:3D commands:reset
initial settings.
- resize (viewport,
(viewSizeDefault),
(viewSizeDefault))
-
resets the width and height
graphics:3D commands:resize
values for a viewport.
- rotate (viewport,
(viewThetaDefapult),
(viewPhiDefault))
-
rotates the viewport by rotation angles for longitude
( ) and
latitude ( ).
Angles designate radians if given as floats, or degrees if given
graphics:3D commands:rotate
as integers.
- setAdaptive3D (boolean(true))
-
sets whether space curves are to be plotted
graphics:plot3d defaults:set adaptive
according to the adaptive
adaptive plotting
refinement algorithm.
- setMaxPoints3D (integer(1000))
-
sets the default maximum number of possible
graphics:plot3d defaults:set max points
points to be used when constructing a three-dimensional space curve.
- setMinPoints3D (integer(49))
-
sets the default minimum number of possible
graphics:plot3d defaults:set min points
points to be used when constructing a three-dimensional space curve.
- setScreenResolution3D (integer(49))
-
sets the default screen resolution constant
graphics:plot3d defaults:set screen resolution
used in setting the computation limit of adaptively
adaptive plotting
generated three-dimensional space curve plots.
- showRegion (viewport, string("off"))
-
declares whether the bounding
graphics:3D commands:showRegion
box of a graph is shown or not.
- subspace (viewport)
-
returns the space component.
- subspace (viewport, subspace)
-
resets the space component
graphics:3D commands:subspace
to subspace.
- title (viewport, string)
-
gives the viewport the
graphics:3D commands:title
title string.
- translate (viewport,
(viewDeltaXDefault),
(viewDeltaYDefault))
-
translates
graphics:3D commands:translate
the object horizontally and vertically relative to the center of the viewport.
- intensity (viewport,float(1.0))
-
resets the intensity I of the light source,
graphics:3D commands:intensity
- tubePointsDefault ([integer(6)])
-
sets or indicates the default number of
graphics:3D defaults:tube points
vertices defining the polygon that is used to create a tube around
a space curve.
- tubeRadiusDefault ([float(0.5)])
-
sets or indicates the default radius of
graphics:3D defaults:tube radius
the tube that encircles a space curve.
- var1StepsDefault ([integer(27)])
-
sets or indicates the default number of
graphics:3D defaults:var1 steps
increments into which the grid defining a surface plot is subdivided with
respect to the first parameter declared in the surface function.
- var2StepsDefault ([integer(27)])
-
sets or indicates the default number of
graphics:3D defaults:var2 steps
increments into which the grid defining a surface plot is subdivided with
respect to the second parameter declared in the surface function.
- viewDefaults ([ ,
, ,
, ,
,
])
-
resets the default settings for the
graphics:3D defaults:reset viewport defaults
point color, line color, axes color, units color, point size,
viewport upper left-hand corner position, and the viewport size.
- viewDeltaXDefault ([float(0)])
-
resets the default horizontal offset
graphics:3D commands:deltaX default
from the center of the viewport, or returns the current default offset if no argument is given.
- viewDeltaYDefault ([float(0)])
-
resets the default vertical offset
graphics:3D commands:deltaY default
from the center of the viewport, or returns the current default offset if no argument is given.
- viewPhiDefault ([float(- /4)])
-
resets the default latitudinal view angle,
or returns the current default angle if no argument is given.
graphics:3D commands:phi default
is set to this value.
- viewpoint (viewport, ,
, )
-
sets the viewing position in Cartesian coordinates.
- viewpoint (viewport,
,
)
-
sets the viewing position in spherical coordinates.
- viewpoint (viewport,
,
,
,
, )
-
sets the viewing position in spherical coordinates,
the scale factor, and offsets.
graphics:3D commands:viewpoint
(longitude) and
(latitude) are in radians.
- viewPosDefault ([list([0,0])])
-
sets or indicates the position of the upper
graphics:3D defaults:viewport position
left-hand corner of a two-dimensional viewport, relative to the display root
window (the upper left-hand corner of the display is ).
- viewSizeDefault ([list([400,400])])
-
sets or indicates the width and height dimensions
graphics:3D defaults:viewport size
of a viewport.
- viewThetaDefault ([float( /4)])
-
resets the default longitudinal view angle,
or returns the current default angle if no argument is given.
graphics:3D commands:theta default
When a parameter is specified, the default longitudinal view angle
is set to this value.
- viewWriteAvailable ([list(["pixmap",
"bitmap", "postscript", "image"])])
-
indicates the possible file types
graphics:3D defaults:available viewport writes
that can be created with the writewriteThreeDimensionalViewport function.
- viewWriteDefault ([list([])])
-
sets or indicates the default types of files
that are created in addition to the data file when a
writewriteThreeDimensionalViewport command
graphics:3D defaults:viewport writes
is executed on a viewport.
- viewScaleDefault ([float])
-
sets the default scaling factor, or returns
graphics:3D commands:scale default
the current factor if no argument is given.
- write (viewport, directory, [option])
-
writes the file data for viewport
in the directory directory.
An optional third argument specifies a file type (one of pixmap, bitmap, postscript, or image), or a
list of file types.
An additional file is written for each file type listed.
- scale (viewport, float(2.5))
-
specifies the scaling factor.
graphics:3D commands:scale
scaling graphs
7.2.11 Customization using .Xdefaults
graphics:.Xdefaults
Both the two-dimensional and three-dimensional drawing facilities consult
the .Xdefaults file for various defaults.
file:.Xdefaults @ .Xdefaults
The list of defaults that are recognized by the graphing routines
is discussed in this section.
These defaults are preceded by Axiom.3D.
for three-dimensional viewport defaults, Axiom.2D.
for two-dimensional viewport defaults, or Axiom* (no dot) for
those defaults that are acceptable to either viewport type.
- Axiom*buttonFont: font
-
This indicates which
graphics:.Xdefaults:button font
font type is used for the button text on the control-panel.
Rom11
- Axiom.2D.graphFont: font
- (2D only)
This indicates
graphics:.Xdefaults:graph number font
which font type is used for displaying the graph numbers and
slots in the Graphs section of the two-dimensional control-panel.
Rom22
- Axiom.3D.headerFont: font
-
This indicates which
graphics:.Xdefaults:graph label font
font type is used for the axes labels and potentiometer
header names on three-dimensional viewport windows.
This is also used for two-dimensional control-panels for indicating
which font type is used for potentionmeter header names and
multiple graph title headers.
Itl14
- Axiom*inverse: switch
-
This indicates whether the
graphics:.Xdefaults:inverting background
background color is to be inverted from white to black.
If on, the graph viewports use black as the background
color.
If off or no declaration is made, the graph viewports use a
white background.
off
- Axiom.3D.lightingFont: font
- (3D only)
This indicates which font type is used for the x,
graphics:.Xdefaults:lighting font
y, and z labels of the two lighting axes potentiometers, and for
the Intensity title on the lighting control-panel.
Rom10
- Axiom.2D.messageFont, Axiom.3D.messageFont: font
-
These indicate the font type
graphics:.Xdefaults:message font
to be used for the text in the control-panel message window.
Rom14
- Axiom*monochrome: switch
-
This indicates whether the
graphics:.Xdefaults:monochrome
graph viewports are to be displayed as if the monitor is black and
white, that is, a 1 bit plane.
If on is specified, the viewport display is black and white.
If off is specified, or no declaration for this default is
given, the viewports are displayed in the normal fashion for the
monitor in use.
off
- Axiom.2D.postScript: filename
-
This specifies
graphics:.Xdefaults:PostScript file name
the name of the file that is generated when a 2D PostScript graph
PostScript
is saved.
axiom2D.ps
- Axiom.3D.postScript: filename
-
This specifies
graphics:.Xdefaults:PostScript file name
the name of the file that is generated when a 3D PostScript graph
PostScript
is saved.
axiom3D.ps
- Axiom*titleFont font
-
This
graphics:.Xdefaults:title font
indicates which font type is used
for the title text and, for three-dimensional graphs,
in the lighting and viewing-volume control-panel windows.
graphics:Xdefaults:2d
Rom14
- Axiom.2D.unitFont: font
- (2D only)
This indicates
graphics:.Xdefaults:unit label font
which font type is used for displaying the unit labels on
two-dimensional viewport graphs.
6x10
- Axiom.3D.volumeFont: font
- (3D only)
This indicates which font type is used for the x,
graphics:.Xdefaults:volume label font
y, and z labels of the clipping region sliders; for the
Perspective, Show Region, and Clipping On buttons under
Settings, and above the windows for the Hither and
Eye Distance sliders in the Viewing Volume Panel of the
three-dimensional control-panel.
Rom8