Showing 3D surface (mexican hat) using parametric function
Source code name: "canvas3D_hplotmx3_hat.py"
Programming language: Python
Topic: Plots/3D
DMelt Version 1.5. Last modified: 09/03/1973. License: Pro
https://datamelt.org/code/cache/canvas3D_hplotmx3_hat_3532.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 jhplot import *
from vmm3d.surface.parametric import SurfaceParametric
from vmm3d.core import RealParamAnimateable,RealParam
from vmm3d.core3D import Vector3D,View3DLit
from java.lang import Math

class torus(SurfaceParametric):
   global aa,bb,cc
   aa=RealParam("genericParam.aa",14)
   bb=RealParam("genericParam.bb",0.5)
   cc=RealParam("genericParam.cc",2)

   def __init__(self):
                self.setU(-2,2) # min and max for U
                self.setV(-2,2)  # min and max for V
                self.setPatchCount(8,8) # number of divisions in X nad Y
                self.setViewpoint(10,-10,10)
                self.setDefaultWindow(-2.5,2.5,-2.5,2.5)
                self.setDefaultOrientation(View3DLit.NO_ORIENTATION);
                self.addParameter(aa)
                self.addParameter(bb)
                self.addParameter(cc)
   def surfacePoint(self, u, v):
       AA=aa.getValue()
       BB=bb.getValue()
       CC=cc.getValue()
       x = u
       y = v
       z = CC * Math.sin( AA/Math.sqrt(1+u*u+v*v) ) * Math.exp(-BB*(u*u+v*v))
       return Vector3D(x,y,z)

c1=HPlotMX()
c1.draw(torus())
c1.visible()



You see the box below because you did not login.