``` 1 # Function. A parametric functions in 3D 2 # S.Chekanov 3 4 from java.awt import Color 5 from jhplot import * 6 7 c1 = HPlot3DP("Canvas",600,600,2,2) 8 c1.visible() 9 10 s1=FPR("ir=.3+.1*sin(4*Pi*u)\nr=ir*sin(2*Pi*v)+.5\nx=r*sin(2*Pi*u)\ny=r*cos(2*Pi*u)\nz=1.5*ir*cos(Pi*v)") 11 s2=FPR("u=-2+4u; v=-2+4v\n\nx=u-(u*u*u/3)+u*v*v\ny=v-(v*v*v/3)+u*u*v\nz=u*u-v*v\n\nn=10; x=x/n; y=y/n; z=z/n") 12 # cylinders 13 s3=FPR("ang=atan2(y,x)\nr2=x*x+y*y\nz=sin(5(ang-r2/3))*r2/3") 14 s4=FPR("u=2 Pi u; z=2(v-.5); x=z cos(u)*.8-1; y=z sin(u)*.8+.6") 15 s5=FPR("u=2 Pi ul; x=cos(u)*.8+.3; y=sin(u)*.8-.6; z=2(v-.5)") 16 s6=FPR("u=2 Pi u; x=cos(u)*.5+.7; y=sin(u)*.5+.7; z=2(v-.5)") 17 helix=FPR("u=1.2 Pi(u-.5); v=5 Pi v\n r=.2\n R=.6\n d=R+cos(u)*r\n z=sin(u)*r+v*.15-.15*5*Pi/2\n x=d cos(v)\n y=d sin(v)") 18 knot=FPR("2 Pi t; r=(1+sin(3t)*.6)*.3; x=r cos(2t)*1.5; y=r sin(2t)*1.5; z=(1+cos(3t)*.6)*.2-(1+.6)*.1") 19 example=FPR("u=Pi n\n v=2 Pi v\n z=cos(u).5\n r=sin(u)\n x=r cos(v)*.6\n y=r sin(v)*.8") 20 sin=FPR("n=2.5 Pi; z=sin(n*x)+sin(n*y); z=z/n") 21 22 23 c1.cd(1,1) 24 c1.draw(s1) 25 26 27 c1.cd(2,1) 28 s2.setFillColor(Color(50,120,90)) 29 c1.draw(s2) 30 31 c1.cd(1,2) 32 helix.setFillColor(Color.green) 33 c1.draw(helix) 34 35 c1.cd(2,2) 36 s3.setLineColor(Color.yellow) 37 c1.draw(s3) 38 39 # c1.clearAll() 40 # c1.update() 41 # export to some image (png,eps,pdf,jpeg...) 42 # c1.export(Editor.DocMasterName()+".png"); ### © jHepWork. S.Chekanov ### ```