iconEuler Examples

Turnery

by R. Grothmann

In this notebook, you can design a rotation object with just a few
mouse clicks. 

First we define a function to read the mouse clicks in a loop.
>function getpoints ...
  setplot(-1,1,-1,1); clg; xplot();
  title("Click into the half plane x>0");
  v=zeros(0,2);
  repeat
    m=mouse(); if cols(m)==1 then break; endif;
    v=v_m; 
    hold on; style("mx"); mark(m[1],m[2]); hold off;
  end;
  return v
endfunction
Now you can try it. Click into right half plane x>0 with monotone
decreasing y.
>v=getpoints()
     0.706104109957       0.93034203097 
     0.819663944618      0.669441115553 
     0.762884027288      0.317792055643 
     0.520623046678    0.00395472260546 
     0.388136572907     -0.294757919684 
     0.331356655577     -0.642625806906 
     0.388136572907      -0.94890079457 
The following commands compute a natural spline, joining the points.
>v=v'; n=cols(v); x=1:n; ...
>s1=spline(x,v[1]); s2=spline(x,v[2]); ...
>t=linspace(1,n,600); ...
>y1=splineval(t,x,v[1],s1); y2=splineval(t,x,v[2],s2); ...
>hold on; plot(y1,y2); hold off; insimg;

Turnery

Now generate a 3D object from these points.
>phi=linspace(0,2*pi,200)';
>X=cos(phi)*y1; Y=sin(phi)*y1; Z=y2;
And plot it.
>plot3d(X,Y,Z,hue=1,frame=0,>user,height=30°, ...
>  zoom=4,<scale,color=rgb(0.2,0,0),amb=0,);  ...
>  insimg();

Turnery

Examples Homepage