 |
A 3D model of snail shell using parametric surface
Source code name: "canvas3D_hplotmx2_snail.java"
Programming language: Java
Topic: Plots/3D
DMelt Version 1.4. Last modified: 09/05/1973. License: Pro
https://datamelt.org/code/cache/canvas3D_hplotmx2_snail_4174.java
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 vmm3d.surface.parametric.*;
import vmm3d.core.RealParamAnimateable;
import vmm3d.core.View;
import vmm3d.core3D.Vector3D;
import vmm3d.surface.SurfaceView;
import jhplot.*;
public class math3d_snail {
static class SnailShell extends SurfaceParametric {
private RealParamAnimateable a = new RealParamAnimateable("a",1.0,1.0,1.0);
private RealParamAnimateable b = new RealParamAnimateable("b",1.4,1.0,1.4);
private RealParamAnimateable c = new RealParamAnimateable("c",0.05,0.1,0.05);
private RealParamAnimateable d = new RealParamAnimateable("d",6.0,2.0,6.0);
public SnailShell() {
addParameter(d);
addParameter(c);
addParameter(b);
addParameter(a);
setDefaultViewpoint(new Vector3D(-40,20,0));
setDefaultWindow(-3.5,3.5,-3.5,3.5);
umin.reset("-pi");
umax.reset("pi");
vmin.reset(-2);
vmax.reset(25);
uPatchCount.setValueAndDefault(30);
vPatchCount.setValueAndDefault(40);
}
public Vector3D surfacePoint(double u, double v) {
double auxa = a.getValue();
double auxb = b.getValue();
double auxc = c.getValue();
double auxd = d.getValue();
double vv = v+(v-vmin.getValue())*(v-vmin.getValue())/16;
double s = Math.exp(-auxc*vv);
double r = s*(auxa+auxb*Math.cos(u));
return new Vector3D(r * Math.cos(vv),auxd-s*(auxd+auxb*Math.sin(u)),r * Math.sin(vv));
}
public View getDefaultView() {
SurfaceView mySurfaceView = new SurfaceView();
mySurfaceView.setGridSpacing(0);
mySurfaceView.setAntialiased(true);
return mySurfaceView;
}
}
public static void main(String [] args) {
HPlotMX c1= new HPlotMX();
c1.draw( new SnailShell());
c1.visible();
}
}
You see the box below because you did not login.