You are a guest. Restricted access. Read more.

Parametric functions

Parametric functions can be constructed using the Java class FPR. The variables “u” and “v” are parametric variables used to build “x,y,z”.

To display such functions, use the canvas HPlot3DP.

Code example

  Download for this example is disabled for non-members
1: from java.awt import Color
2: from jhplot import *
3: c1 = HPlot3DP("Canvas")
4: c1.setGTitle('3D surfaces')
5: c1.visible();
6: f1=FPR('u=2 Pi u; z=1.5*(v-.5); x=z cos(u)*.8-0; y=z sin(u)*.8+0')
7: f1.setFillColor(Color.green)
8: c1.draw(f1)

The output of this script is shown here

A parametric function

One can overlay several functions on top of each other and set the transparency level. In this example we show this:

Code example

  Download for this example is disabled for non-members
 1: from java.awt import Color
 2: from jhplot import *
 3:
 4: c1 = HPlot3DP("Canvas",500,600)
 5: c1.setGTitle('Sphere and torus')
 6: c1.visible()
 7:
 8: # a transparent sphere
 9: f1=FPR('r=0.6; u=2 Pi u; v=Pi v; x=r cos(u) sin(v); y=r sin(u) sin(v); z=r cos(v)')
10: f1.setDivisions(20,20)
11: f1.setLineColor(Color.blue)
12: f1.setFillColor( Color(20,170,170, 100) )
13:
14: # a tour
15: f2=FPR('u=2 Pi u; v=2 Pi v; r=0.7+.2cos(u); z=.2 sin(u)-0.0; x=r cos(v); y=r sin(v)')
16: f2.setDivisions(30,30)
17: f2.setFillColor( Color(200,170,170,255) )
18:
19: c1.draw(f1)
20: c1.draw(f2)

The execution of this script brings up a window with this figure:

A parametric function from  jhplot Java package

Information for advanced users

If you are a registered SCaVis user, please go to this link Working with IDE for advanced users

click here if you want to know more

click here if you want to know more

click here if you want to know more

A complete description of how to use Java, Jython and SCaVis for scientific analysis is described in the book Scientific data analysis using Jython and Java published by Springer Verlag, London, 2010 (by S.V.Chekanov)

Sergei Chekanov 2013/03/07 16:37

Navigation

Print/export