next up previous contents index
Next: Utility Functions Up: Reference Manual Previous: Lines and Planes   Contents   Index

Domains and Plotting

To fix terminology, the noun ``map'' will be used for a C++ function that accepts one or more double arguments or a P argument, and returns a double or a P. Maps can be depicted in two mathematically useful ways: graphing (which retains information about the domain), and drawing the image as a parametrized curve or surface (which discards domain information). Usually, a double-valued map is graphed, while a P-valued map is viewed parametrically. The verb ``plot'' is used generically to mean either sort of depiction, and the noun ``plot'' refers to the result of plotting.

The ``domain'' of a map is the set of allowed input values. In ePiX, a domain is a coordinate box of dimension one, two, or three. For uniformity, a 2-dimensional domain is actually a 3-dimensional domain whose ``thickness'' along the $ x_3$-axis is 0. Similarly, a 1-dimensional domain is a ``highly degenerate'' 3-dimensional domain. Domains facilitate the plotting of families of mappings, and the selective plotting of parts of a mapping; domain operators for these purposes are described below.

A plot depends on a map and a domain. For example, suppose f is a P-valued map of two (double) variables, and R is a two-dimensional domain. To construct a plot, subdivide R with a ``coarse'' rectangular mesh, say having $ m_1\times m_2$ sub-rectangles. For each ``grid line'', plot the parametric curve obtained by evaluating f along the line. The result is the (wiremesh) plot of f over R.

A detail was omitted in the preceding paragraph: the number of points plotted in each parametric curve. Many graphing programs use as many points as dictated by the coarse mesh, so that the surface is made of quadrilaterals (Figure 3.2, left). In ePiX, a domain possesses a ``fine'' mesh, say that divides R into $ n_1\times
n_2$ subrectangles (Figure 3.2, right). The individual parametric curves comprising the surface are drawn using the fine subdivisions. A plot can conform to the ``true'' surface without requiring many quadrilaterals.

Figure 3.2: A surface with coarse ($ 6\times 18$) and fine ( $ 12\times 60$) meshes.

A domain is defined by giving a pair of opposite corners, the coarse mesh, and the fine mesh. A domain's meshes are independent; the fine mesh need not be a ``multiple'' of the coarse mesh. Indeed, the ``fine'' mesh may be more coarse than the ``coarse'' mesh. Usually, however, the fine mesh is a ``small multiple'' of the coarse mesh.

A domain can be resized in any coordinate direction for which the thickness is positive, using object-oriented syntax. For the domain R above,

  domain R_new = R.resize2(0.5,0.75);
defines a new domain having opposite corners $ (0,0.5)$ and $ (1,0.75)$. To the extent possible, resizing attempts to preserve absolute grid sizes. In this example, the new domain has $ 6\times4$ coarse mesh ( $ 18/4=4.5\to4$) and $ 12\times15$ fine mesh. It's best to choose meshes so that resizing does not cause integer truncation.

A domain can be sliced by setting one variable to a constant; the result is a domain whose dimension is one smaller than the original:

  domain R1 = R.slice1(0.3);
creates the 1-dimensional domain with endpoints $ (0.3,0)$ and $ (0.3,1)$, and having coarse mesh 18 and fine mesh 60. Resizing and slicing commands may be used directly in a plot command:
  plot(f, R.slice1(0.3));
draws the parametric curve obtained by slicing R at $ x_1=0.3$, then applying f.

For plotting families of maps, a domain has ``slices'' operators that return the list of domain slices obtained by setting one variable to components of the coarse mesh:

\begin{center}\vbox{\input{slices.eepic}
}\end{center}

When plotting a function of one variable, constructing a domain is possible but tedious. The command

  plot(f, t_min, t_max, n);
plots f over the interval [t_min, t_max] using n subintervals (n+1 points).

The ability to slice or resize makes domains more useful when plotting functions of two or three variables. The commands below typify plot commands; $ f$ is a function of one variable, and $ F$ is a function of 2 or 3 variables. If the function is real-valued, the graph is drawn; otherwise the image is drawn.

  // two ways to plot F on [a,b] x [c,d]
  plot(F,  P(a,c), P(b,d), mesh(N1,N2), mesh(n1,n2));

  domain R(P(a,c), P(b,d), mesh(N1,N2), mesh(n1,n2));
  plot(F, R);

  plot(F, R.slice1(a));      // plot F on part of the boundary
  plot(F, R.slices1());      // plot F over all slices x1=const
A function of 3 variables can be plotted over a 1- or 2-dimensional domain, while a function of 2 variables cannot be plotted over a 3-dimensional domain.



Subsections
next up previous contents index
Next: Utility Functions Up: Reference Manual Previous: Lines and Planes   Contents   Index
Andrew D. Hwang 2004-09-04