This is an old revision of the document!
Table of Contents
Plots in 3D
SCaVis contains several powerful engines to draw functions, histograms, data and various primitives in 3D. Graphics is fully interactive thus one can rotate objects, insert text etc. Many of such engines are 100% native to Java.
Several canvaces which can be used to show math objects are shown below:
|HPlot3D||is used for plotting data in 3D H2D, P2D, P3D, F2D|
|HPlotXYZ||is used for plotting data and geometrical objects in 3D using OpenGL. Can be used to show H2D, P3D, F2D|
|HPlot3DP||is used for plotting parametric and non-parametric functions such as FPR|
Showing data in 3D (X-Y-Z plots)
SCaVis has many engines to render 3D graphics in fully interactive way. This is rather large topic which is discussed in Section 3D graphics. In this section we just show a few rather basic examples.
3D graphics from OFF files
Here is an example to read OFF files. In this case we read the file “teapot.off”
from jhpro.engine3d import * view=HEngine3D("teapot.off") view.setBounds(10, 10, 600, 400) view.setVisible(1)
Read about the definitions of the OFF file Section OFF file description This engine does not support showing mathematical functions nor displaying axises.
There are several methods to change the color, transparency, and the solid style.
Advanced 3D graphics
This is the most powerful engine to render 3D graphics and mixing mathematical objects and graphical primitives.
Here is an example which shows how to draw interactive geometrical shapes in the 3D canvas using Java and Jython. The code shown below is written in Jython/Python and contains only 10 lines.
Functions in 3D
One can plot functions in 3D, overlaying any number of functions and applying custom colors. Below a simple Jython example which shows this using 10 lines of code (similarly, one can rewrite this example in Java):
Now we will make a more complicated function: instead of giving a string defining a function, we will build a complex function using the Python language. Our function will look as this:
if x>0: z=a*y*x+b*sin(y) if x<0: z=c*cos(x*y)+sin(y)
As you can see, it has 3 parameters a,b,c. Now let us create a small code snipped to draw such function. We put comments which explain each step:
Math objects in 3D
One can draw the following mathematical objects: arrays of points with custom sizes and color, histograms and mathematical functions in 3D. All such objects can be overplayed on the same canvas. Below is a small script which plots several datasets in 3D (with blue and red points), functions as surfaces and H2D histograms:
Histograms can be shown using different style. In the above example we use “rainbow” color style for the histogram. One can also show it using solid color or as a surface: