DMelt:Plots/JavaView
Using JavaView
3D geometry viewer and a mathematical visualization software, called JavaView (http://www.javaview.de/) can be used
with the class
jhplot.HJavaView. It should be noticed that the license of JavaView should be put to the file "lib/javaview/rsrc/jv-lic.lic" relative to DataMelt installation.
Without this license, the program is fully functional but you will see a message dialog about the license.
The package allows:
Visualize and study your own geometry models. The data files may reside on your local computer or somewhere on the internet. Simply browse your local disk or type the URL of a model using a web form.
- Solve ordinary differential equations interactively.
- Calculate the zero points of functions.
- Measure distances on curved polyhedral surfaces using straightest or shortest geodesic lines.
- Computes algebraic surfaces given as zero set of a polynomial function.
DataMelt allows programming and visualizing 3D mathematical objects using the Python language (as well as Groovy, Ruby). Here is a Jython example that shows
a snail in 3D interactive viewer:
The code is shown below:
from jv.geom import PgElementSet
from jhplot import HJavaView
obj = PgElementSet(3);
obj.setName("snail");
obj.computeSnail(40, 30, 2.0);
#obj.computeSphere(40, 10, 2.0);
obj.flipOrientation();
obj.makeVertexNormals();
obj.makeElementNormals();
obj.makeElementColorsFromZ();
obj.showElementColors(True);
obj.showElementBackColor(True);
obj.setTransparency(0.1);
obj.showTransparency(True);
obj.showSmoothElementColors(True);
obj.showSmoothLighting(True);
c1= HJavaView()
c1.draw(obj)
c1.visible()
One can draw several 3D objects which belong to
jv.geom.PgElementSet class.
Showing functions in 3D
Here is an example which illustrates how to calculate parametric functions. Here is an example that illustrates how to create Kuen Surface
The code is shown below uses the
jvx.surface.PgParmSurface class:
# Describes parametrized surfaces over a two dimensional domain.
# Parameter domain allows adjustments.
# Konrad Polthier, Sergei Chekanov
from jv.function import PuFunction
from jvx.surface import PgDomainDescr,PgParmSurface
from jhplot import HJavaView
from java.lang import Math
dimOfDomain = 2
numFunctions = 3
m_domain = PgDomainDescr(dimOfDomain)
m_domain.setName("Domain of Kuen")
m_domain.setMaxSize(-10., -10., 10., 10.)
m_domain.setSize(-4.5, 0.05, 4.5, Math.PI-.05)
m_domain.setDiscr(16, 16)
m_domain.init()
m_function = PuFunction(dimOfDomain, numFunctions)
m_parmSurface = PgParmSurface(numFunctions)
m_parmSurface.setName("Kuen Surface")
m_function.setName("Functions of Kuen")
m_function.setExpression(0, "2./(1.+(u*sin(v))^2)*sqrt(1.+u*u)*sin(v)*cos(u-atan(u))")
m_function.setExpression(1, "2./(1.+(u*sin(v))^2)*sqrt(1.+u*u)*sin(v)*sin(u-atan(u))")
m_function.setExpression(2, "log(tan(v/2.))+2./(1.+(u*sin(v))^2)*cos(v)")
m_parmSurface.setFunctionExpr(m_function)
m_parmSurface.setDomainDescr(m_domain)
m_parmSurface.compute()
# add some colors
m_parmSurface.showElementColors(True);
m_parmSurface.showElementBackColor(True);
m_parmSurface.setTransparency(0.2);
m_parmSurface.showTransparency(True);
m_parmSurface.showSmoothElementColors(True);
m_parmSurface.showSmoothLighting(True);
c1=HJavaView()
c1.visible()
c1.draw(m_parmSurface)
DataMelt supports drawing all JavaView classes that inherent from the Java class
jv.project.PgGeometry. Below are several examples
implemented using the Python language:
Drawing standard 2D functions
You can plot the standard
jhplot.F2D functions using
jhplot.HJavaView. You can use either the "draw(F2D)" method,
or "add(F2D)" method. The latter returns
jv.project.PgGeometry object which can be used to modify style of the function (color, transparency).
For example,
from jhplot import HJavaView,F2D
c1=HJavaView()
f1=F2D("x*y",-1,1,-1,1)
obj=c1.add(f1) # now you can add some style
c1.draw(obj)
Similarly, one can draw arrays of functions, or one can repeat "draw()" to overlay functions.