In addition to the HPlot, HPlot2D, HPlot3D canvaces, SCaVis offers another canvas for for visualizing and experimenting with a variety of mathematical objects or “exhibits.” This class is called
The class is based on 3D-XplorMath program of the 3DXM Consortium. ScaVis uses the base code of this program but adds a support for vector graphics i.e. one can export images to EPS, SVG or PDF formats. Thus, all images are fully scalable and are ready to be included to publications. If you need a similar program but with animation support (but without vector graphics export), use the ScaVis IDE (“See the Plot menu).
Here is a simple Jython script which creates a predefined paraboloid:
from jhplot import * c1=HPlotMX("vmm3d.surface.parametric.Paraboloid") c1.visible()
Here we simply call the class name that defines “Paraboloid”. The output of this script is shown below:
A similar example can be rewritten in BeanShell, Groovy or Java languages. Here is the same example in the Groovy scripting. Make a file “test.groovy”, and run it in ScaVis:
import jhplot.* c1=new HPlotMX("vmm3d.surface.parametric.Paraboloid") c1.visible()
In the above example we simply call the class name that defines a paraboloid function, see
vmm3d.surface.parametric.Paraboloid class. There are about 60 predefined parametric mathematical functions that can be called to display. They are listed above with the corresponding Java API:
From the above list, one can pick up any math object and path its name as
java.lang.String. Alternatively, one can construct
mathematical exhibit by creating the object itself:
from jhplot import * from vmm3d.surface.parametric import * c1=HPlotMX() ks=KuenSurface() # create Kuen Surface c1.draw(ks) c1.visible()
The output is shown below:
As usual, use the method “export” to create an image file. For example, we can create EPS, PDF and SVG figures using the vector formats as:
c1.export("KuenSurface.eps") c1.export("KuenSurface.pdf") c1.export("KuenSurface.svg")
Now we consider how to draw custom parametric or non-parametric functions, instead of showing predefined functions.
First we create a function of torus using pure-Java approach:
The defined torus will be shown below:
Instead of defining the function as a Java code, one can define it inside the same Jython script that is used to show the canvas with the object. Here is a simple Jython code to do this:
Run this Jython/Python script and you will see the identical torus. You can change any parameters. For example, inserting “setV(0,2)”, we will generate only a part of the torus as shown bellow:
You can reduce the number of patches used to draw the torus, making this picture rendering faster.
Here is the same method to create a torus using Groovy scripting: