Easter eggs as Matlab code
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear Matlab community,
Unfortunately I ran out of eggs. I've looked in the FileExchange and found christmas trees, valentine hearts, fireworks and a surprisingly large number of arrows and progressbars. But unfortunately no eggs, most of all no beautiful easter eggs.
I'd be very glad if you could provide some colored eggs as Matlab code.
Please vote all nice solutions.
THANKS!
3 Commenti
Risposta accettata
Daniel Shub
il 18 Mar 2013
As inspiration you might want to check out how to make eggs in LaTeX. I used that as my starting point. I was thinking about an answer where I just hack tex.m to include the code, but I think TikZ requires PDF output and not DVI and I am not sure tex.m can handle pdf output.
t = -pi:0.01:pi;
H = 1;
x = H*0.78.*cos(t./4).*sin(t);
y = -H*cos(t);
fill(x, y, [1, 0.87, 0.68])
axis square
axis([-1, 1, -1, 1]);
axis off
The next step would be to make it 3D, and then play with color, lighting/shading and texture. It is a start ...
0 Commenti
Più risposte (3)
Leah
il 18 Mar 2013
Okay here is my egg so far. I would like to have a fancy color map, but I thought others might like to make one. I used Dan's post (link below), his are very fancy
c=.2;
b=1.7;
theta=linspace(0,2*pi,40);
phi=linspace(0,pi,40);
[theta,phi]=meshgrid(theta,phi);
x=(1+c*phi).*sin(phi).*cos(theta);
y=(1+c*phi).*sin(phi).*sin(theta);
z=b*cos(phi);
M=mesh(x,y,z,'facecolor','interp','facelighting','phong');
cmap=colormap(jet);
linspace(0,2*pi,32)
axis equal
axis off
0 Commenti
Sean de Wolski
il 18 Mar 2013
Thanks for the Monday challenger.
[x,y,z] = sphere(100);
x = 1.7./(1-0.4*x);
figure(10);
h = surf(x,y,z);
cdata = imresize(imread('onion.png'),size(x));
set(h,'CDataMapping','Direct','FaceColor','texturemap','CData',cdata);
0 Commenti
Image Analyst
il 18 Mar 2013
At first I thought you meant that they took the Easter eggs (like spy, why, penny, etc.) out of the new version of MATLAB. But then I figured out you actually want code to draw pictures of fancy design Easter eggs. I don't have any code for that. I wish they'd refresh their Easter eggs - they're getting kind of stale.
I do have some nice puzzler codes though. One to solve a maze, and another that does a Monte Carlo simulation on the Monty Hall problem, which I haven't posted anywhere, but I could if anyone is interested.
Here's one I ran across that was kind of fun because it's counter-intuitive (though it's really easy to solve): "You have 100 pounds of Martian potatoes, which are 99 percent water by weight. You let them dehydrate until they’re 98 percent water. How much do they weigh now?"
1 Commento
Vedere anche
Categorie
Scopri di più su Holidays / Seasons in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!