Thank God for sudo apt-get install scilab! Thank God for Ubuntu! Thank God for centered circle sample code! Thank God for user-friendly Scilab tutorials in the internet!
Here are the outputs for the activity:
Figure 1. (top row left) Centered square, (top row middle) Corrugated roof, (top row right) grating, (middle row left) Annulus, (middle row center) Gaussian graded transparency, (middle row right) Ellipse, (bottom row) Cross
Playing around with the code, here are other produced outputs:
Figure 2. (top left) Graded square, (top middle) Checker board, (top right) Elliptic Annulus, (bottom left) Grating + Sinusoid, (bottom right) Annulus + Checker board + Sinusoid
For this activity, I give myself an 11 (GOING BEYOOONNNNNDDD!!!)
Here are the codes used for the required images:
//Centered square aperture x = linspace(-1,1,1000); y = linspace(-1,1,1000); [X,Y] = ndgrid(x,y); A = zeros(1000,1000); rx = sqrt(X.^2); ry = sqrt(Y.^2); A(find(rx<0.3 & ry<0.3)) = 1; f = scf(); grayplot(x,y,A); f.color_map = graycolormap(32);
//Grating along the x-direction x = linspace(-1,1,500); y = linspace(-1,1,500); [X,Y] = ndgrid(x,y); z = sin(X.*12); f = scf(); grayplot(x,y,z); f.color_map = graycolormap(32);
//Grating along the x-direction x = linspace(-1,1,500); y = linspace(-1,1,500); [X,Y] = ndgrid(x,y); A = zeros(500,500); z = sin(X.*12); A(find(z<-0)) = 1; f = scf(); grayplot(x,y,A); f.color_map = graycolormap(32);
//Annulus x = linspace(-1,1,500); y = linspace(-1,1,500); [X,Y] = ndgrid(x,y); A = zeros(500,500); r = sqrt(X.^2 + Y.^2); A(find(r<0.7 & r>0.3)) = 1; f = scf(); grayplot(x,y,A); f.color_map = graycolormap(32);
//Circular aperture with graded transparency (Gaussian transparency) function y=gauss(x), y=exp(-(x)/2), endfunction x = linspace(-1,1,1000); y = linspace(-1,1,1000); [X,Y] = ndgrid(x,y); r = gauss(sqrt(X.^2+Y.^2)); r(find(r<0.7))=-0.5; f = scf(); grayplot(x,y,r); f.color_map = graycolormap(32);
//Ellipse x = linspace(-1,1,500); y = linspace(-1,1,500); [X,Y] = ndgrid(x,y); A = zeros(500,500); r = sqrt((X.^2)/4 + (Y.^2)/2); A(find(r<0.4)) = 1; f = scf(); grayplot(x,y,A); f.color_map = graycolormap(32);
//Cross x = linspace(-1,1,500); y = linspace(-1,1,500); [X,Y] = ndgrid(x,y); A = zeros(500,500); rx = sqrt(X.^2); ry = sqrt(Y.^2); A(find(rx<0.2 | ry<0.2)) = 1; A(find(rx>0.9 | ry>0.9)) = 0; f = scf(); grayplot(x,y,A); f.color_map = graycolormap(32); Blog post won't be complete without a success gif sooo :)))