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.

from java.awt import Color
from jhplot import HPlot3DP,FPR
c1 = HPlot3DP("Canvas")
c1.setGTitle('3D surfaces')
c1.visible();
f1=FPR('u=2 Pi u; z=1.5*(v-.5); x=z cos(u)*.8-0; y=z sin(u)*.8+0')
f1.setFillColor(Color.green)
c1.draw(f1)

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

from java.awt import Color
from jhplot import FPR,HPlot3DP

c1 = HPlot3DP("Canvas",500,600)
c1.setGTitle('Sphere and torus')
c1.visible()

# a transparent sphere
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)')
f1.setDivisions(20,20)
f1.setLineColor(Color.blue)
f1.setFillColor( Color(20,170,170, 100) )

# a tour
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)')
f2.setDivisions(30,30)
f2.setFillColor( Color(200,170,170,255) )

c1.draw(f1); c1.draw(f2)

scavis/functions/fpr.txt · Last modified: 2013/04/14 16:52 (external edit)