# Easter eggs as Matlab code

조회 수: 5 (최근 30일)
Jan . 2013년 3월 18일
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.
THANKS!
##### 댓글 수: 3이전 댓글 2개 표시이전 댓글 2개 숨기기
Jan 2013년 3월 18일
@Leah: Text and sound is welcome also, when an ovate shape can be recognized. The more beautiful, the better.
Of course I will show, what I have done so far also.

댓글을 달려면 로그인하십시오.

### 채택된 답변

Daniel Shub 2013년 3월 18일
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.
The LaTeX answers provide a link to the shape of an egg. That is enough to get started
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 ...

댓글을 달려면 로그인하십시오.

### 추가 답변 (3개)

Leah 2013년 3월 18일
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이전 댓글 -1개 표시이전 댓글 -1개 숨기기

댓글을 달려면 로그인하십시오.

Sean de Wolski 2013년 3월 18일
Thanks for the Monday challenger.
[x,y,z] = sphere(100);
x = 1.7./(1-0.4*x);
figure(10);
h = surf(x,y,z);
set(h,'CDataMapping','Direct','FaceColor','texturemap','CData',cdata);
##### 댓글 수: 0이전 댓글 -1개 표시이전 댓글 -1개 숨기기

댓글을 달려면 로그인하십시오.

Image Analyst 2013년 3월 18일
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없음 표시없음 숨기기
Jan 2013년 3월 18일
편집: Jan 님. 2013년 3월 18일
Let me reformat your text a little bit:
"You
have 100
pounds of Martian
potatoes, which are
99 percent water by
weight. You let them
dehydrate until they
are 98 percent water.
How much do they
they weigh
now?"

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Holidays / Seasons에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by