 |
A 3D model of snail shell using parametric surface
Source code name: "canvas3D_hplotmx_snail.groovy"
Programming language: Groovy
Topic: Plots/3D
DMelt Version 1.5. Last modified: 09/05/1973. License: Pro
https://datamelt.org/code/cache/canvas3D_hplotmx_snail_2793.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 vmm3d.surface.parametric.SurfaceParametric;
import vmm3d.core.RealParamAnimateable;
import vmm3d.core.View;
import vmm3d.core3D.Vector3D;
import vmm3d.surface.SurfaceView;
import jhplot.HPlotMX;
class SnailShell extends SurfaceParametric {
RealParamAnimateable a = new RealParamAnimateable("a",1.0,1.0,1.0)
RealParamAnimateable b = new RealParamAnimateable("b",1.4,1.0,1.4)
RealParamAnimateable c = new RealParamAnimateable("c",0.05,0.1,0.05)
RealParamAnimateable d = new RealParamAnimateable("d",5.0,2.0,5.0)
SnailShell() {
addParameter(d)
addParameter(c)
addParameter(b)
addParameter(a)
setDefaultViewpoint(new Vector3D(-20,20,0))
setDefaultWindow(-3.5,3.5,-3.5,3.5)
setU(-Math.PI,Math.PI)
setV(-2,25)
uPatchCount.setValueAndDefault(32)
vPatchCount.setValueAndDefault(64)
}
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.0
double s = Math.exp(-auxc*vv)
double r = s*(auxa+auxb*Math.cos(u))
double rr= auxd-s*(auxd+auxb*Math.sin(u))
return new Vector3D(r*Math.cos(vv),rr,r*Math.sin(vv))
}
View getDefaultView() {
SurfaceView mySurfaceView = new SurfaceView()
mySurfaceView.setGridSpacing(0)
mySurfaceView.setAntialiased(true)
return mySurfaceView
}
}
c1= new HPlotMX()
c1.draw( new SnailShell())
c1.visible()
You see the box below because you did not login.