{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PaintMoon

# PaintMoon - D d = 0.1 P = 28 P for x=(hc-r:d(hc r-d f%for...

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

% 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')
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

{[ snackBarMessage ]}

Ask a homework question - tutors are online