<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Baubles in Orbit</title>
    <link>http://blog.objectmentor.com/articles/2008/08/19/baubles-in-orbit</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Baubles in Orbit</title>
      <description>&lt;p&gt;I have put together a nice little demonstration of the Bauble concept.  You may recall that I first wrote about it &lt;a href="http://blog.objectmentor.com/articles/2008/07/20/bauble-bauble"&gt;here&lt;/a&gt;.  Baubles are a simple component scheme for Ruby, good for when you want a component, but don&amp;#8217;t need something as heavy as a gem.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://fitnesse.org/files/unclebob/orbit.zip"&gt;orbit.zip&lt;/a&gt; contains all the files for this demonstration.  I suggest you download and unpack it.&lt;/p&gt;


	&lt;p&gt;First you need to install the Bauble gem.  Don&amp;#8217;t worry, it won&amp;#8217;t hurt anything.  Just say &lt;code&gt;gem install orbit/bauble/Bauble-0.1.gem&lt;/code&gt; (You&amp;#8217;ll probably have to do it with &lt;code&gt;sudo&lt;/code&gt;.)  That should install Bauble.  From now on you only need to say &lt;code&gt;require 'bauble'&lt;/code&gt; in your ruby scripts that make use of it.&lt;/p&gt;


Now you should be able to run the orbital simulator.  Just type:
&lt;pre&gt;&lt;code&gt;
cd orbit/MultipleBodyOrbit/lib
jruby multiple_body_orbit.rb
&lt;/code&gt;&lt;/pre&gt;
A swing window should pop up and you should be able to watch an orbital simulation.  Every run shows a different random scenario, so you can kill a lot of time by watching worlds in collision.

	&lt;p&gt;The thing to note, if you are a ruby programmer, is the use of the term &lt;code&gt;Bauble::use(-some_directory-)&lt;/code&gt;.  If you look in the &lt;code&gt;multiple_body_orbit.rb&lt;/code&gt; file you&amp;#8217;ll see I use two Baubles, the &lt;code&gt;Physics&lt;/code&gt; bauble does the raw calculation for all the gravity, forces, collisions, etc.  The &lt;code&gt;cellular_automaton&lt;/code&gt; bauble provides a very simple Swing framework for drawing dots on a screen. (Yes, this is jruby).&lt;/p&gt;


	&lt;p&gt;If you look in either of the two Baubles, you&amp;#8217;ll see that the &lt;code&gt;require&lt;/code&gt; statements within them do not know (or care) about the directory they live in.  There is none of that horrible &lt;code&gt;__FILE__&lt;/code&gt; nonsense that pollutes so many ruby scripts.  This is because the &lt;code&gt;Bauble::use&lt;/code&gt; function puts the directory path in the &lt;code&gt;LOAD_PATH&lt;/code&gt; so that subsquent &lt;code&gt;require&lt;/code&gt; statements can simply eliminate the directory spec.&lt;/p&gt;


	&lt;p&gt;Take a look at the Bauble source code.  It&amp;#8217;s no great shakes.&lt;/p&gt;


	&lt;p&gt;Also take a look at the two baubles.  They show a pretty nice way to decouple business rules from gui.  You might recognize the &lt;span class="caps"&gt;MVP&lt;/span&gt; pattern.  The &lt;code&gt;multiple_body_orbit.rb&lt;/code&gt; file contains the presenter.  Clearly the &lt;code&gt;Physics&lt;/code&gt; module is the model.  And the &lt;code&gt;cellular_automaton&lt;/code&gt; module is the view. (There is no controller, because there is no input.)&lt;/p&gt;</description>
      <pubDate>Tue, 19 Aug 2008 01:29:32 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f2909460-a819-4cd3-93db-ec5b15b1a8cb</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2008/08/19/baubles-in-orbit</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Dynamic Languages</category>
      <category>Design Principles</category>
      <category>Clean Code</category>
    </item>
    <item>
      <title>"Baubles in Orbit" by ipad video converter</title>
      <description>&lt;p&gt;have  read it 
it is good&lt;/p&gt;</description>
      <pubDate>Mon, 19 Apr 2010 22:13:46 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:bf54fcda-c682-4973-a28d-2e5b5a95942e</guid>
      <link>http://blog.objectmentor.com/articles/2008/08/19/baubles-in-orbit#comment-10205</link>
    </item>
    <item>
      <title>"Baubles in Orbit" by Kooba Handbags   </title>
      <description>&lt;p&gt;Living without an aim is like sailing without a compass.
with a new &lt;a href="http://www.handbags4buy.com/" rel="nofollow"&gt;http://www.handbags4buy.com/&lt;/a&gt; idea is a crank until the idea succeeds.&lt;/p&gt;</description>
      <pubDate>Thu, 01 Apr 2010 01:22:41 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:3491b7fc-7096-4956-aeb5-a9c602b101f6</guid>
      <link>http://blog.objectmentor.com/articles/2008/08/19/baubles-in-orbit#comment-9004</link>
    </item>
    <item>
      <title>"Baubles in Orbit" by EGHM</title>
      <description>&lt;p&gt;&lt;/p&gt;


	&lt;p&gt;Very cool!  Took me a while to realize it was working, so I added @frame.setBackground(Color.black) to cellular_automaton.makeFrame and change the point color to white in multiple_body_orbit.draw if I knew a bit more about how configuration was done I would have taken a stab at putting these two things that changed together, together.&lt;/p&gt;</description>
      <pubDate>Thu, 21 Aug 2008 05:49:45 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:3b4875fe-9e03-4639-ad54-0eb256f627d3</guid>
      <link>http://blog.objectmentor.com/articles/2008/08/19/baubles-in-orbit#comment-1995</link>
    </item>
    <item>
      <title>"Baubles in Orbit" by unclebob</title>
      <description>&lt;blockquote&gt;
		&lt;p&gt;jruby -S gem install orbit/bauble/Bauble-0.1.gem&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Ah yes!  Thanks for the correction.&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;why are the trajectories wobbly?&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;The view pins the sun at the origin.  Massive objects that orbit the sun make it wobble in normal space.  That translates to a wobble of the entire background.  In essence you are seeing all the orbits from the point of view of the sun.&lt;/p&gt;


	&lt;p&gt;In our own skies, the trajectories of all the planets wobble because we ride on the Earth.  So the motion of the Earth is superimposed onto the motion of the rest of the planets.  In this simulation you are riding on the Sun, and large planets make the Sun wobble.&lt;/p&gt;</description>
      <pubDate>Tue, 19 Aug 2008 13:20:50 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:c221e240-b51c-4345-bd4d-64ef00debb0f</guid>
      <link>http://blog.objectmentor.com/articles/2008/08/19/baubles-in-orbit#comment-1987</link>
    </item>
    <item>
      <title>"Baubles in Orbit" by Micah Martin</title>
      <description>&lt;p&gt;&lt;b&gt;note:&lt;/b&gt; The gem has to be installed in your instance of jruby. 
&lt;br /&gt;&lt;code&gt;&amp;#38; jruby -S gem install orbit/bauble/Bauble-0.1.gem&lt;/code&gt;
&lt;br /&gt;&lt;br /&gt;
Very cool simulator!  I find myself watching it over and over. However, why are the trajectories wobbly?  I don&amp;#8217;t recall them being so in the previous version you showed me.&lt;/p&gt;</description>
      <pubDate>Tue, 19 Aug 2008 05:00:54 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:536b87a9-e045-4f9b-b261-f555c81fa48e</guid>
      <link>http://blog.objectmentor.com/articles/2008/08/19/baubles-in-orbit#comment-1986</link>
    </item>
  </channel>
</rss>
