PaintMoon - % period P is defined to be 28 days P for...

Info iconThis preview shows pages 1–2. 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 % Draws a square of width=length=twice circle radius at the correct lower % left endpoint [(hc-r,vc-r)] % DrawRect(hc-r,vc-r,2*r,2*r,'k') D % Draws a yellow disk of radius r, inside the black square, centered at % the input (hc,vc) % DrawDisk(hc,vc,r,'y') D d = 0.1; % increment P = 28;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % period P is defined to be 28 days P for x=(hc-r):d:(hc+r-d) % iterate through in x-direction w/ incr. d f for y=(vc-r+d):d:(vc+r) % iterate through in y-direction w. incr. d if (T<=(P/2))&&(T>=0) % T in days is less than or equal to 14 g = hc + (cos(2*pi*T/P))*(sqrt(r^2-((y-vc)^2))); if x <= g % Pt. is in dark region so draw dark square DrawRect(x,y-d,d,d, 'k'); end else % T in days is greater than 14 h = hc - (cos(2*pi*T/P))*(sqrt(r^2-((y-vc)^2))); if x >= h % Pt. is in dark region so make square dark 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).

Page1 / 2

PaintMoon - % period P is defined to be 28 days P for...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online