iconEuler Home

Christmas Stars and Envelopes

The idea to the following plots is due to Ron Gerber. He did that using my geometry program C.a.R.

The following flower shape is well known.

>x=linspace(0,2pi,1000); ...
 plot2d(cos(4*x)*cos(x),cos(4*x)*sin(x)):

Ron Gerber

Now take the points in steps of 1°.

>x=(0:360)°; ...
 plot2d(cos(4*x)*cos(x),cos(4*x)*sin(x),>points):

Ron Gerber

If we connect every 31st point, we get a very nice shape.

>fullwindow; ...
 x=mod((0:360)*31,360)°; ...
 plot2d(cos(4*x)*cos(x),cos(4*x)*sin(x),grid=0,r=1):

Ron Gerber

Ron procuded other shapes adding parameters.

Ron Gerber

>function plotstar ([m,e,r]) ...
 fullwindow();
 m=floor(m); e=floor(e); r=floor(r);
 x=mod((0:360)*r,360)°;
 plot2d(cos(m*x)^e*cos(x),cos(m*x)^e*sin(x),grid=0);
 endfunction

Using dragvalues(), you can experience various nice shapes.

>v=dragvalues("plotstar",["M","E","R"],[4,2,31],[0,12;1,10;1,50]); ...
 plotstar(v):

Ron Gerber

Compute Envelopes

The curves that appear in the plots above are envelopes of sets of lines. We can compute such envelopes using the intersections of each two lines.

First the curve.

>function g(t) := cos(4*t)*[cos(t);sin(t)]; ...
 t=(0:361)°; P=g(t); ...
 fullwindow(); plot2d(P[1],P[2],r=0.95,grid=0):

Ron Gerber

Now we compute the curve with an offset of 31°.

>Q=g(t+31°);

We add the line segments connecting the points of P and Q to the plot.

>plot2d((P[1]_Q[1])',(P[2]_Q[2])',color=gray,>add,thickness=0.5):

Ron Gerber

To compute the envelope, we intersect pairs of these segments using simple linear algebra. In our case, everything works and no two lines are parallel.

>function getenv (P,Q) ...
 n=cols(P);
 E=zeros(2,n-1);
 D=Q-P;
 for i=1 to n-1;
   A=D[,[i,i+1]];
   b=P[,i]-P[,i+1];
   x=A\b;
   E[,i]=P[,i]-x[1]*D[,i];
 end;
 return E;
 endfunction
>E=getenv(P,Q); ...
 plot2d(E[1],E[2],color=red,>add,thickness=2):

Ron Gerber

Reset the fullwindow() state.

>reset;

Euler Home