]7ec@sdZddlmZmZmZmZddlmZdZ de fdYZ defdYZ d Z ed kre end S( s turtle-example-suite: tdemo_planets_and_moon.py Gravitational system simulation using the approximation method from Feynman-lectures, p.9-8, using turtlegraphics. Example: heavy central body, light planet, very light moon! Planet has a circular orbit, moon a stable orbit around the planet. You can hold the movement temporarily by pressing the left mouse button with the mouse over the scrollbar of the canvas. i(tShapetTurtletmainlooptVec2D(tsleepitGravSyscBs#eZdZdZdZRS(cCsg|_d|_d|_dS(Nig{Gz?(tplanetstttdt(tself((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyt__init__s  cCs"x|jD]}|jq WdS(N(Rtinit(R tp((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyR scCsKxDtdD]6}|j|j7_x|jD]}|jq/Wq WdS(Ni'(trangeRRRtstep(R tiR ((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pytstart!s(t__name__t __module__R R R(((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyRs  tStarcBs,eZdZdZdZdZRS(cCsptj|d||j||_|j|||_|jj|||_|j d|j dS(Ntshapetuser( RR tpenuptmtsetpostvRtappendtgravSyst resizemodetpendown(R RtxRRR((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyR (s      cCs:|jj}|j|_|jd||j|_dS(Ng?(RRtacctaR(R R((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyR 2s cCsrtdd}x\|jjD]N}||kr|j|j}|t|jt|d|7}qqW|S(Nii(tVecRRtpostGRtabs(R R tplanetR((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyR6s  *cCs|jj}|j|j||j|jjj|dkrh|j|j|jjdn|j |_ |j||j |_dS(Ni( RRRR"RRtindext setheadingttowardsRR (R R((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyR=s  #(RRR R RR(((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyR's  cCst}|j|jdd|j|j|jd|jd|j|jdd|j |j }|j|jdd|j |j }t d}|j |d|j |d|j jd||jd dt}td tddtdd |d }|jd |jd|jtdtddtdd|d}|jd|jdtd tddtdd|d}|jd|jd|j|jdS(NiiiZitcompoundtorangetblueR%ii@Bgtcircletyellowg?i0iitgreeng?ii'g?sDone!(Rtresetttracerthttputfdtltt begin_polyR,tend_polytget_polyRt addcomponentt getscreentregister_shapeRRR!tcolort shapesizetpencolorR R(tstm1tm2t planetshapetgstsuntearthtmoon((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pytmainGsD              *   *  *    t__main__N(t__doc__tturtleRRRRR!ttimeRR#tobjectRRRFR(((s9/usr/lib64/python2.7/Demo/turtle/tdemo_planet_and_moon.pyts" '