X P L O T, Version Beta Feb. 9 1994 Maorong Zou, Dept. of Math. UT Austin In[1]:This means xplot has been succesfully loaded and it is ready for your inputs.
In[1]: ex1 =surface{[sin(x)*cos(y)][x: -pi,pi][y: -pi,pi]};After the above line has been entered, an object called ex1 is defined (assuming there are no syntax errors). To plot it, just enter the following command.
In[2]: plot ex1;In just a few seconds, a window will pop out and the object ex1 is displayed in it with the default graphics attributes.
Move the mouse into the main display window, press the left button and move the pointer around. Notice how the object moves. The left button is tied to rotation about the screen axis. The middle button is tied to screen translation and the right button is binded to scaling.
The object can also be transformed by sliding the three sliders around the main display window. These sliders are controled by the first six menu buttons on the bottom of the display window. Among which the C Slider button is probably the most useful one, it resets all sliders to their center position. Initially, the sliders are binded to rotations about the screen coordinates.
You may have noticed that when you move the object, only part of it is visiable. This is a feature designed to make intermediate transition between frames smooth. You can disable this feature by pressing the Fast button once.
In case you lose your object, there is a button in the lower right corner called Reset View , push it once will undo all the translations. You can also look at the top right window to see where is your object. The part inside the yellow box is the visible part of your object.
When the Material menu button is pressed, the gadget panel will be updated. You can modify many of the material properties there by pressing buttons and/or sliding sliders.
You can also change the background color and the light source by pressing the Light menu button and modifying the corresponding gadgets in the gadget panel.
In[3]: sphere = surf{[2*sin(x)*cos(y),2*sin(x)*sin(y),2*cos(x)]\ [x=0:pi][y=0:2*pi][sample=20:30]}; In[4]: torus = tube{[4*sin(x),4*cos(x),0][x=0:2*pi][sample=400:20]\ [radius=0.5*abs(sin(x))]}; In[5]: plot sphere, torus;
In[6]: curve_example=curve{[sin(x)*(5+cos(20*x)),\ cos(x)*(5+cos(20*x)),sin(20*x)]\ [x: 0,2*pi][sample=2000][color=green]}; In[10]: plot curve_example;Observe the picture. Can you tell which part of the curve is nearest to you? Now it is the time to use the depthcue shading by pressing the Depthcue button on the gadget panel. If you cannot find this button there, press the Misc menu button on the top menubar, it will bring the initial gadgets back.
If you have both curves and surfaces in your display, depthcueing is not the best coloring scheme. In these case, you can achieve a better coloring by check the Lighted Line button on the gadget panel. Of course, you have to disable the depthcueing by check the Fixed light src box once or twice.
In[11]: load "xp.xample"will load all the commands in file xp.example ,
In[1]: set dummy t s;To see what the current dummy variables are, use the show dummy command.
In[2]: a = sin(1.0)*sqrt(2.0); In[3]: b = a^12 + 1.3; In[4]: f(x,y,z) = x^2+x*y*z+z*z +sgn(x)*( abs(x))^0.3; In[5]: g(x,y) = (x >= y)? (x+a): y*f(y,x,1); In[6]: h(x,y) = log(abs(sinh(x+y))); In[7]: j(x) = x * 0.001 * ( rand() % 1000);Xplot accepts most of the standard math functions and math operators.
Important Note:
xplot only accepts functions of at most 4 variables.
where= keyword { }
For example,
In[1]: curve_example=curve{[``curve_data''][sample: 2345]\ [color: cyan][style: points]};For surfaces,
#------------------------------------------------------ # This is a half-sphere with 2 caps removed. Notice the # y range is a function of x. In[2]: sphere2 = surface{[-sqrt(1-x*x-y*y)][x: -0.8:0.8]\ [y: -sqrt(1-x*x):sqrt(1-x*x)] \ [sample: 30:30]}
#------------------------------------------------------ # The following surface is the famous Mandelbrot set. # To plot it, use 'plot2d Mandelbrot' . In[5]: M(x,y,z,w) = \ ( (w>100)?(0.1) : \ ((real(z)**2+imag(z)**2>10000.0)?(0.001*w) :\ ( M(x,y,z*z+x+y*i,w+1)) ) ); In[6]: m_set=surface{[M(x,y,0,0)][x=-1.8:0.8][y=-1.1:1.1] \ [sample=100:100] }; #------------------------------------------------------ # The Julia set for the map z -> z*z + (0.32+0.043*i) # To plot, use 'plot2d Julia' . In[8]: creal = 0.32; cimag = 0.043; J(x,y,z)=( (z>100)?(0.1): \ ((x*x+y*y>10000.0)? (0.001*z): \ (J(x*x-y*y+creal,2.0*x*y+cimag,z+1)))); In[9]: j_set = surface{[J(x,y,0)][x=-1.0:1.0][y=-1.2:1.2] \ [sample=100:100]}; #------------------------------------------------------
where tube is the keyword,= tube { }
# ------------------------------------------------------ # a torus knot # tx(x) = sin(2*x)*(10.0 + 6*cos(3*x)); ty(x) = cos(2*x)*(10.0 + 6*cos(3*x)); tz(x) = 6*sin(3*x); tknot = tube{[tx(x),ty(x),tz(x)][x=0:2*pi][sample=100:10] [radius=0.5+ 0.1* sin(x)]} # ------------------------------------------------------ # The trifoil knot # set dummy t; tref = tube{ [ -2*cos(t)- 1/2*cos(5*t)+ 3*sin(2*t), -3*cos(2*t)+ 2*sin(t)- 1/2*sin(5*t), 2*cos(3*t)] [ t=0: 2*pi][sample=100:20][radius=0.4]}; # ------------------------------------------------------
# ----- iterate a discrete map and plot its trajectory----- In[3]: a=1.4; b=0.3; HX(x,y)=y+1-a*x**2; HY(x,y)=b*x; In[4]: henonMap=map{[HX(x,y),HY(x,y)] [initial: 0.4,0.5][iterate: 5000] }; # ----- solve ODEs and plot its trajectory ----- # ----- notice here we group the relevent function ----- # ----- definitions in a single command ----- In[5]: function definitions { RR = 28.0; LORdy1dt (x,y,z) = 10.0* (y - x); LORdy2dt (x,y,z) = RR* x - x*z - y; LORdy3dt (x,y,z) = x* y - 8.0* z /3.0; }; In[6]: LorenzAttractor=ode{[ LORdy1dt(x,y,z), LORdy2dt(x,y,z),LORdy3dt(x,y,z)] [initials = 0.03: 0.12: 0.1] [time = 0.0:70.0 ] [step = 0.002] [skip 6] }; In[7]: lambda = 3.5; f(x) = lambda * x*(1-x); In[8]: a = cur{[x,f(x),0][x=0:1][samples=300][color=red]}; In[9]: b = cur{[x,x,0] [x=0,1][sample=10][color=green]}; # # (x, y) -> (y, f(x)) # The z-component is not relevent (in plot2d) but it is # helpful to get a depthcue shading. # In[10]: c = map{[y,f(x),0.002+z][initial=0.1,f(0.1),-1] [iterates=400][color=blue][style=solid]}; In[11] qmap= obj{ a,b,c }; #---------------------------------------------------------------
Defining an object from a data file is similar to defining an object from coordinate functions, with the coordinate functions replaced by the file name (in quotes). For example, suppose you have a set of 30 by 50 grid data saved in a file called grid.data and you want to define an object from it. You may use the following command.
In[1]: grid_surf=surface{[``grid.data''][sample: 30,50]};We remark that a grid data of size N by 1, which is just N points, can be used to define a curve or a tube.
#--------------------------------------------------------- # cube.off # a cube in OFF format 8 6 # 8 vertices, 6 polygons. 0 0 0 # list of the 8 vertices. 1 0 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 4 0 1 2 3 # list of the 6 polygons. 4 7 6 4 5 # Note: you need to figure 4 2 3 7 6 # out the orientation 4 1 2 6 5 # yourself. Indices 4 0 1 5 4 # starts at 0 4 3 0 4 8And the following input
In[20]: cube = sur{["cube.off"]}defines the corresponding xplot object.
In[1]: macro = ``f(x,y)=sin(x)*cos(y)''defines a macro called macro which stands for the string on the right. Later reference of the string can be achieved by using $(macro) . For example,
In[2]: $(macro);has the same effect as
In[3]: f(x,y)=sin(x)*cos(y);One restriction for macro expansion is that macros and variables cannot have the same name. If this happens, xplot will interpret the macro as the value of the variable (the actural macro definition is not accessible). For example,
In[4]: a = 100; In[2]: a = ``f(x,y) = x+y''; In[3]: $(a); (unknown command) In[4]: print $(a); 100
set dummy args | Set the dummy variables. For example: |
In[1]: set dummy u v; |
|
The default dummy variables are x,y,z and w | |
show dummy | Print the current dummy variables. |
set title string | Set the plot title, for example: |
In[1]: set title "The (3,4) Torus knot" | |
set notitle | Disable the plot title. |
reset | Sometimes when errors occur, the command interpreter and the graphics driver cannot communicate well. If this happens, the reset command will clear the trouble. |
plot objects | Plot the specified objects. |
plot2d objects | Same as plot , but set the view point on the positive z axis. |
replot | Redo the last plot. |
show arg | Print the objects you defined so far. The arg can be f, g or a where f stands for functions, g for simple objects and a for everything. |
save arg 'file' | Save the specified objects into 'file', where arg is the same as in above. |
load 'file' | Execute all the commands in 'file' . |
print variable | Print the value of the variable. |
! unix-command | Shell escape. |
exit (or quit) | Exit from xplot. |
<identifier> = curve{ <geometry> <attributes>} <geometry> ::= [ < 3 one variable functions>] [<dummy-var>=<expression>:<expression>] | ["data_file"] <attributes> ::= [samp=<expression>] [color= <red>|<green>|<blue>|<magenta>| <yellow>|<cyan>|<white>] [style = <-1>|<0>]
<identifier> = surface { <geometry> <attributes> } <geometry> ::= [<a 2 variable function>] | [<three 2 variable functions>] [<dummy-var1>=<expression>:<expression>] [<dummy-var2>=<expression>:<expression>] | ["data_file"] <attributes> ::= [samp=<expression>:]
<identifier> = tube { <geometry> <attributes> } <geometry> ::= [< three 1 variable functions>] [<dummy-var1>=<expression>:<expression>] | ["data_file"] [radius =<expression>] <attributes> ::= [samp=<expression>:<expression>]
<identifier> = map { <specification> <attributes>} <specification> ::= [<map definition>] [initials=<expressions separated by ,>] [iterates=<integer expression>] <attributes> ::= [ color = <red>|<green>...]Note: xplot will only plot the first 3 coordinates.
<identifier> = ode{ <specification> <attributes>} <specification> ::= [ <expression for dx/dt ...>] [initials=<expression>|<expression> ...] [time = <expr>:<expr>] <attributes> ::= [step=<expr>] [skip: <integer expression>] [method: <RK> | <RKQC>] [style: <dotted>|<solid>] [color: <red>|<green>| ...] if(method == RKQC) the following attributes may be specified: [small= <expression>] [scale: <expression>:<expression>...]Again, xplot will only plot the first 3 coordinates.