PaintMoon - D d = 0.1; P = 28; P for x=(hc-r):d:(hc+r-d) f...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% Function PaintMoon % Eric Young / CS 100M % function PaintMoon(hc,vc,r,T) f % Draws the moon as it appears T days after the new moon. % T = 0 or 28 corresponds to the new moon. % T = 14 corresponds to the full moon. % The moon is centered at (hc,vc) and has radius r (positive integer). % axis equal off hold on h DrawRect(hc-r,vc-r,2*r,2*r,'k') DrawDisk(hc,vc,r,'y')
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: D d = 0.1; P = 28; P for x=(hc-r):d:(hc+r-d) f %for y=(vc-r+d):d:(vc+r) y=sqrt(r^2-x^2); if (T<=(P/2))&&(T>=0) g = hc + (cos(2*pi*T/P))*(sqrt(r^2-((y-vc)^2))); if x <= g %DrawRect(x,y-d,d,d, 'k'); DrawRect(x,,d,d, 'k'); end else h = hc - (cos(2*pi*T/P))*(sqrt(r^2-((y-vc)^2))); if x >= h DrawRect(x,y-d,d,d, 'k'); end end end end e...
View Full Document

This note was uploaded on 09/12/2009 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Ask a homework question - tutors are online