<?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>dev.enekoalonso.com &#187; planet</title>
	<atom:link href="http://dev.enekoalonso.com/tag/planet/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.enekoalonso.com</link>
	<description>having fun with code</description>
	<lastBuildDate>Wed, 12 Oct 2011 21:40:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Gravity in the DOM</title>
		<link>http://dev.enekoalonso.com/2008/12/18/gravity-in-the-dom/</link>
		<comments>http://dev.enekoalonso.com/2008/12/18/gravity-in-the-dom/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 05:58:27 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[gravity]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[planet]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[thread]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=166</guid>
		<description><![CDATA[A couple of days ago I created a demo to simulate planets on a 2D universe interacting each other like Gravity does in our lives. To compute the movements every planet had to be evaluated with each other on every step. Their position will be affected by the other planet position and in proportion to [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I created a demo to simulate planets on a 2D universe interacting each other like Gravity does in our lives. To compute the movements every planet had to be evaluated with each other on every step. Their position will be affected by the other planet position and in proportion to their respective mass. This means the speed of the planets doesn&#8217;t impact the attraction between them.</p>
<p>Today I decided to extend this demo a little bit more and I added a few things:</p>
<ul>
<li>Mass parameter to make mass independent from size.</li>
<li>Collision detector to merge planets when they meet each other with color effect.</li>
<li>Orbit trails</li>
</ul>
<p><a href="http://dev.enekoalonso.com/research/gravity-2.php"><img src="http://dev.enekoalonso.com/wp-content/uploads/2008/12/picture-143-415x300.png" alt="Gravity" title="Gravity" width="415" height="300" class="aligncenter size-medium wp-image-186" /></a></p>
<p>The result is very nice. The first option make it possible to create bigger planets with more mass but with a size that fits appropiately on the screen. The second option merged planets that collide, making it more like a real world. Finally, the orbit trails are just some sugar to see the trajectory followed by the plantes. To avoid the screen getting very messy, the trails clean up themselves after 25 seconds.</p>
<p>As you can see, the universe controller uses the <a href="http://dev.enekoalonso.com/2008/12/14/threads-in-javascript/">Thread class</a> I was talking about few days ago.</p>
<p>See both demos here:<br />
<a href="http://dev.enekoalonso.com/research/gravity.php">http://dev.enekoalonso.com/research/gravity.php</a><br />
<a href="http://dev.enekoalonso.com/research/gravity-2.php">http://dev.enekoalonso.com/research/gravity-2.php</a></p>
<p>PS: Please note there is no Canvas involved here. All objects on screen are DOM elements. Of course this is not the best way to do graphic animations on the web, but it is fun!</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>January 15, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/15/i-never-use-on-my-projects-and-barely-use/" title="I never use $$ on my projects (and barely use $)">I never use $$ on my projects (and barely use $)</a> (0)</li><li>April 23, 2009 -- <a href="http://dev.enekoalonso.com/2009/04/23/sending-messages-between-javascript-objects/" title="Sending messages between Javascript objects">Sending messages between Javascript objects</a> (2)</li><li>December 14, 2008 -- <a href="http://dev.enekoalonso.com/2008/12/14/threads-in-javascript/" title="Threads in Javascript">Threads in Javascript</a> (1)</li><li>May 6, 2011 -- <a href="http://dev.enekoalonso.com/2011/05/06/finding-duplicate-ids-on-an-html-page/" title="Finding duplicate ID&#8217;s on an HTML page">Finding duplicate ID&#8217;s on an HTML page</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2008/12/18/gravity-in-the-dom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

