<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>numlock.ch - a changelog by Daniel Mettler &#187; Doodle</title>
	<atom:link href="http://www.numlock.ch/news/tag/doodle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.numlock.ch/news</link>
	<description>make a diff :)</description>
	<lastBuildDate>Thu, 12 Aug 2010 07:45:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick analysis of the first animated Google doodle (&#8220;Isaac Newton&#8217;s apple&#8221;)</title>
		<link>http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/</link>
		<comments>http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 23:26:50 +0000</pubDate>
		<dc:creator>mettlerd</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[animated Doodle]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Doodle]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Isaac Newton]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.numlock.ch/news/?p=806</guid>
		<description><![CDATA[You probably noticed the funny animated logo on the Google search page today, January 4, 2010 (Isaac Newton&#8217;s birthday). It shows an apple falling from a tree reminding of the story that Isaac Newton was inspired to formulate his theory of gravitation by watching the fall of an apple from a tree.

Animation of an apple [...]]]></description>
			<content:encoded><![CDATA[<p>You probably noticed the funny animated logo on the <a href="http://www.google.com/" target="_blank">Google search page</a> today, January 4, 2010 (Isaac Newton&#8217;s birthday). It shows an apple falling from a tree reminding of the story that <a href="http://en.wikipedia.org/wiki/Isaac_Newton" target="_blank">Isaac Newton</a> <a href="http://en.wikipedia.org/wiki/Isaac_Newton#Newton.27s_apple" target="_blank">was inspired to formulate his theory of gravitation by watching the fall of an apple from a tree</a>.</p>
<p><a href="http://www.numlock.ch/news/wp-content/uploads/2010/01/google_search_page_apple_isaac_newton.png"><img class="aligncenter size-medium wp-image-809" title="Screenshot of Google's doodle in memory of Isaac Newton's birthday" src="http://www.numlock.ch/news/wp-content/uploads/2010/01/google_search_page_apple_isaac_newton-300x252.png" alt="Screenshot of Google's doodle in memory of Isaac Newton's birthday" width="300" height="252" /></a></p>
<p><a href="http://www.numlock.ch/news/wp-content/uploads/2010/01/2010-01-05_0016.swf">Animation of an apple falling from a tree in Google&#8217;s doodle in memory of Isaac Newton&#8217;s birthday</a></p>
<p>As this seems to be the first animated logo on Google&#8217;s home page ever, I wondered how it was implemented (in particular, how well the code simulates gravity on earth). Short explanation: As expected, it&#8217;s a mix of JavaScript code and CSS formatting. And not surprising either, the algorithm used is an acceptable simulation of gravity on earth (in vacuum).</p>
<p>Here&#8217;s a &#8220;reformatted&#8221; version of the JavaScript code for better readability, along with some explanations as <span style="color: #008000;">inline comments</span> (note that this &#8220;reformatted&#8221; code doesn&#8217;t work as-is due to the inserted comments):</p>
<blockquote>
<pre>window.lol&amp;&amp;lol();
setTimeout( <span style="color: #008000;">// execute this code once after a timeout of 2 seconds</span>
  function(){ <span style="color: #008000;">// an anonymous function</span>
    var h=0, <span style="color: #008000;">// initial horizontal offset (=0) of the apple's position</span>
    v=1, <span style="color: #008000;">// initial vertical offset ('delta_height' = b(t+1)-b(t)) of the apple's position</span>
    f=document.getElementById('fall'), <span style="color: #008000;">// get a reference to the apple image</span>
    i=setInterval( <span style="color: #008000;">// execute repeatedly in intervals of 25 msec</span>
      function(){ <span style="color: #008000;">// yet another anonymous function</span>
        if(f){ <span style="color: #008000;">// execute if the apple image exists</span><span style="color: #008000;"> (a safety net)</span>
          var r=parseInt(f.style.right)+h,<span style="color: #008000;"> // add the horizontal offset (will move apple left for h&gt;0)</span>
          b=parseInt(f.style.bottom)-v;<span style="color: #008000;"> // subtract the vertical offset (will move apple down for v&gt;0)</span>
          f.style.right=r+'px';<span style="color: #008000;"> // set the apple's new horizontal position</span>
          f.style.bottom=b+'px';<span style="color: #008000;"> // set the apple's new vertical position</span>
          if(b&gt;-210){ <span style="color: #008000;">// the apple is above ground level (i.e. falling down or bouncing up)</span>
            v+=2 <span style="color: #008000;">// increase 'delta_height' by 2 pixels per interval (accelerate the apple's free fall or slow down its rebound)</span>
          } else { <span style="color: #008000;">// the apple hit the 'ground'</span>
            h=(v&gt;9)?v*0.1:0; <span style="color: #008000;">// bounce apple to the left at 10% of the last 'delta_height' if speedy, else don't move it horizontally</span>
            v*=(v&gt;9)?-0.3:0 <span style="color: #008000;">// bounce apple up at 30% of the last 'delta_height' if speedy, else don't move it vertically</span>
          }
        }
      }
      ,25 <span style="color: #008000;">// the interval in msec</span>
    );
    google.rein&amp;&amp;
    google.rein.push(
      function(){
        clearInterval(i); <span style="color: #008000;">// disable the interval loop</span>
        h=0;v=1
      }
    )
  },2000 <span style="color: #008000;">// the timeout in msec</span>
)
</pre>
</blockquote>
<p>The apple&#8217;s initial position:<em> position: relative; right: 248px; bottom: 46px;</em></p>
<p>The apple&#8217;s final position (after the rebound):<em> position: relative; right: 286px; bottom: -210px;</em></p>
<p><strong>Some words about the physics:</strong></p>
<p>The simple algorithm used above reflects the constant <a href="http://en.wikipedia.org/wiki/Free_fall" target="_blank">acceleration during free fall</a> accurately, supposed we&#8217;re neglecting the effect of air drag. IOW: height(t) = height(t=0) &#8211; 0.5*g*t^2 = h(t=0) &#8211; k*t^2.</p>
<p>The rebound of the apple is less realistic though. I doubt an apple would rebound that high and the fact that it rebounds to the left seems to be rather arbitrary (given the image it&#8217;s difficult to judge where the apple&#8217;s center of gravity would be compared to the contact area when touching the ground on impact). Further, simulating rotational forces on the apple wouldn&#8217;t hurt the realism ;)</p>
<p><strong>Symbolism:</strong></p>
<p>It&#8217;s not without irony that Google shows a falling <a href="http://www.apple.com/" target="_blank">apple</a> on its main page, as one reader points out on <a href="http://mashable.com/2010/01/04/google-newton-animated-logo/" target="_blank">Mashable&#8217;s article about this animation</a> ;)</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;t=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;title=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29+-+http://tinyurl.com/yz9myuc&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29&amp;body=Link: http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A You%20probably%20noticed%20the%20funny%20animated%20logo%20on%20the%20Google%20search%20page%20today%2C%20January%204%2C%202010%20%28Isaac%20Newton%27s%20birthday%29.%20It%20shows%20an%20apple%20falling%20from%20a%20tree%20reminding%20of%20the%20story%20that%20Isaac%20Newton%20was%20inspired%20to%20formulate%20his%20theory%20of%20gravitation%20by%20watching%20the%20fall%20of%20an%20apple%20from%20a%20tree.%0D%0A%0D" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;title=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;t=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;t=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29" rel="nofollow" class="external" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="shr-posterous">
			<a href="http://posterous.com/share?linkto=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;title=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29&amp;selection=You%20probably%20noticed%20the%20funny%20animated%20logo%20on%20the%20Google%20search%20page%20today%2C%20January%204%2C%202010%20%28Isaac%20Newton%27s%20birthday%29.%20It%20shows%20an%20apple%20falling%20from%20a%20tree%20reminding%20of%20the%20story%20that%20Isaac%20Newton%20was%20inspired%20to%20formulate%20his%20theory%20of%20gravitation%20by%20watching%20the%20fall%20of%20an%20apple%20from%20a%20tree.%0D%0A%0D" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;title=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/&amp;title=Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-techmeme">
			<a href="http://twitter.com/home/?status=Tip+@Techmeme+http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/+&quot;Quick+analysis+of+the+first+animated+Google+doodle+%28%22Isaac+Newton%27s+apple%22%29&quot;&amp;source=shareaholic" rel="nofollow" class="external" title="Tip this to TechMeme">Tip this to TechMeme</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.numlock.ch/news/it/quick-analysis-of-the-first-animated-google-doodle-isaac-newton-apple/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
