 |
Several parametric functions FRP in 3D canvas (HPlot3DP)
Source code name: "canvas3D_func_param0.py"
Programming language: Python
Topic: Plots/3D
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/canvas3D_func_param0_3210.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from java.awt import Color
from jhplot import *
c1 = HPlot3DP("Canvas",600,600,2,2)
c1.visible()
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)")
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")
# cylinders
s3=FPR("ang=atan2(y,x)\nr2=x*x+y*y\nz=sin(5(ang-r2/3))*r2/3")
s4=FPR("u=2 Pi u; z=2(v-.5); x=z cos(u)*.8-1; y=z sin(u)*.8+.6")
s5=FPR("u=2 Pi ul; x=cos(u)*.8+.3; y=sin(u)*.8-.6; z=2(v-.5)")
s6=FPR("u=2 Pi u; x=cos(u)*.5+.7; y=sin(u)*.5+.7; z=2(v-.5)")
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)")
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")
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")
sin=FPR("n=2.5 Pi; z=sin(n*x)+sin(n*y); z=z/n")
c1.cd(1,1)
c1.draw(s1)
c1.cd(2,1)
s2.setFillColor(Color(50,120,90))
c1.draw(s2)
c1.cd(1,2)
helix.setFillColor(Color.green)
c1.draw(helix)
c1.cd(2,2)
s3.setLineColor(Color.yellow)
c1.draw(s3)
# c1.clearAll()
# c1.update()
# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png");
You see the box below because you did not login.