derived from Pluecker Conoid
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax Canvas.setpenopacity(1); // Global code will be evaluated once. const turtle = new Turtle(); turtle.penup(); turtle.goto(0,0); turtle.pendown(); 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=50; // min=0, max=360, step=1 const rotatey=50; // min=0, max=360, step=1 const rotatez=50; // min=0, max=360, step=1 const scale=30; // min=0, max=100, 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=-3.14;u<=3.14;u=u+0.04) { for(v=-1.0;v<=1.0;v=v+0.1) { x=v*Math.cos(u)*nx*scale y=v*Math.sin(u)*ny*scale z=Math.sin(u)*nz*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); } } return false }