 |
Create 3D torus using interactive HPlotMX
Source code name: "canvas3D_hplotmx1.py"
Programming language: Python
Topic: Plots/3D
DMelt Version 1. Last modified: 08/29/2015. License: Pro
https://datamelt.org/code/cache/canvas3D_hplotmx1_7760.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",1.75)
bb=RealParam("genericParam.bb",0.4)
cc=RealParam("genericParam.cc",0.4)
def __init__(self):
self.setU(0,2*3.142) # min and max for U
self.setV(0,2*3.142) # 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 = (AA + BB * Math.cos(u))* Math.cos(v)
y = (AA + BB * Math.cos(u))* Math.sin(v)
z = CC * Math.sin(u)
return Vector3D(x,y,z)
c1=HPlotMX()
c1.draw(torus())
c1.visible()
# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png");
You see the box below because you did not login.