Create 3D torus using interactive HPlotMX
Source code name: "canvas3D_hplotmx1.groovy"
Programming language: Groovy
Topic: Plots/3D
DMelt Version 1. Last modified: 08/29/2015. License: Pro
https://datamelt.org/code/cache/canvas3D_hplotmx1_4141.groovy
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.



import jhplot.*
import vmm3d.surface.parametric. *
import vmm3d.core.*
import vmm3d.core3D.*
import java.lang.Math


public class Torus extends SurfaceParametric {

        private RealParam aa = new RealParam("genericParam.aa","1.75");
        private RealParam bb = new RealParam("genericParam.bb","0.4");
        private RealParam cc = new RealParam("genericParam.cc","0.4");


        public Torus() {
                uPatchCount.setValueAndDefault(12);
                vPatchCount.setValueAndDefault(32);
                umin.reset("0");
                umax.reset("2 pi");
                vmin.reset("0");
                vmax.reset("2 pi");
                setDefaultViewpoint(new Vector3D(10,-10,10));
                setDefaultWindow(-2.5,2.5,-2.5,2.5);
                setDefaultOrientation(View3DLit.NO_ORIENTATION);
                addParameter(aa);
                addParameter(bb);
                addParameter(cc);
        }

        public Vector3D surfacePoint(double u, double v) {
            double AA = aa.getValue();
            double BB = bb.getValue();
            double CC = cc.getValue();
            double x = (AA + BB * Math.cos(u))* Math.cos(v);
                double y = (AA + BB * Math.cos(u))* Math.sin(v);
                double z = CC * Math.sin(u);
                return new Vector3D(x,y,z);
        }

}
 

c1=new HPlotMX()
c1.draw(new Torus())
c1.visible()
// c1.export(Editor.DocMasterName()+".png");


You see the box below because you did not login.