# Describes parametrized surfaces over a two dimensional domain.
# Show a half sphere  

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("Half Sphere")
m_domain.setMaxSize(-2., -2., 2., 2.)
m_domain.setSize(-Math.PI, Math.PI, 0, 2*Math.PI)
m_domain.setDiscr(20, 20)
m_domain.init()

m_function= PuFunction(dimOfDomain, numFunctions)
geom= PgParmSurface(numFunctions)
geom.setName("Half Sphere")

m_function.setName("Helix")
m_function.setExpression(0, "2*sin(v)*cos(u)")
m_function.setExpression(1, "2*sin(v)*sin(u)")
m_function.setExpression(2, "2*cos(v)")
geom.setFunctionExpr(m_function)

geom.setDomainDescr(m_domain)
geom.compute()

# add some colors
geom.showElementColors(True);
geom.showElementBackColor(True);
geom.setTransparency(0.5);
geom.showTransparency(True);

geom.makeElementColorsFromXYZ()
geom.showElementColors(True)

c1=HJavaView()
c1.visible()
c1.draw(geom)

