Hyperbolic Helicoid
3d-meier.de/tut3/seite26.html
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(.7);
// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
turtle.goto(0,0);
draw=0; // first line is always wrong
//const nx=1; // min=0, max=10, step=1
//const ny=1; // min=0, max=10, step=1
//const nz=1; // min=0, max=10, step=1
const rotatex=240; // min=0, max=360, step=1
const rotatey=170; // min=0, max=360, step=1
const rotatez=150; // min=0, max=360, step=1
const scale=74; // min=0, max=100, step=1
const a=2.8; // min=-10, max=10, step=.1
x=.0
y=.0
z=.0
u=.0
v=.0
// The walk function will be called until it returns false.
function walk()
{
for(u=-4;u<=4;u=u+0.04)
{
for(v=-4;v<=4;v=v+0.04)
{
x=Math.sinh(v)*Math.cos(a*u)/(1+Math.cosh(u)*Math.cosh(v))*scale
y=Math.sinh(v)*Math.sin(a*u)/(1+Math.cosh(u)*Math.cosh(v))*scale
z=Math.cosh(v)*Math.sinh(u)/(1+Math.cosh(u)*Math.cosh(v))*scale
// Rotation in x
xn=x
yn=y*Math.cos(rotatex/360*2*3.1415)-z*Math.sin(rotatex/360*2*3.1415)
zn=y*Math.sin(rotatex/360*2*3.1415)+z*Math.cos(rotatex/360*2*3.1415)
x=xn
y=yn
z=zn
// Rotation in y
xn=x*Math.cos(rotatey/360*2*3.1415)+z*Math.sin(rotatey/360*2*3.1415)
yn=y
zn=-x*Math.sin(rotatey/360*2*3.1415)+z*Math.cos(rotatey/360*2*3.1415)
x=xn
y=yn
z=zn
// Rotation in y
xn=x*Math.cos(rotatez/360*2*3.1415)-y*Math.sin(rotatez/360*2*3.1415)
yn=x*Math.sin(rotatez/360*2*3.1415)+y*Math.cos(rotatez/360*2*3.1415)
zn=z
// convert to isometric view, orthographic
// x' = (x - z) * cos(θ)
// y' = y + (x + z) * sin(θ)
// θ = 30° for isometric
xiso=((xn-zn)*Math.cos(3.1415/6))
yiso=(yn+(xn+zn)*Math.sin(3.1415/6))
turtle.goto(xiso,yiso);
if (draw==0) // ignore first line
{
turtle.pendown();
draw=1;
}
}
}
return false
}