Baubles in Orbit 50

Posted by Uncle Bob Tue, 19 Aug 2008 06:29:32 GMT

I have put together a nice little demonstration of the Bauble concept. You may recall that I first wrote about it here. Baubles are a simple component scheme for Ruby, good for when you want a component, but don’t need something as heavy as a gem.

orbit.zip contains all the files for this demonstration. I suggest you download and unpack it.

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

Now you should be able to run the orbital simulator. Just type:

cd orbit/MultipleBodyOrbit/lib
jruby multiple_body_orbit.rb
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.

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

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

Take a look at the Bauble source code. It’s no great shakes.

Also take a look at the two baubles. They show a pretty nice way to decouple business rules from gui. You might recognize the MVP pattern. The multiple_body_orbit.rb file contains the presenter. Clearly the Physics module is the model. And the cellular_automaton module is the view. (There is no controller, because there is no input.)

Comments

Leave a response

  1. Avatar
    Micah Martin about 4 hours later:

    note: The gem has to be installed in your instance of jruby.
    & jruby -S gem install orbit/bauble/Bauble-0.1.gem

    Very cool simulator! I find myself watching it over and over. However, why are the trajectories wobbly? I don’t recall them being so in the previous version you showed me.

  2. Avatar
    unclebob about 12 hours later:

    jruby -S gem install orbit/bauble/Bauble-0.1.gem

    Ah yes! Thanks for the correction.

    why are the trajectories wobbly?

    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.

    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.

  3. Avatar
    EGHM 2 days later:

    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.

  4. Avatar
    Kooba Handbags about 1 year later:

    Living without an aim is like sailing without a compass. with a new http://www.handbags4buy.com/ idea is a crank until the idea succeeds.

  5. Avatar
    ipad video converter about 1 year later:

    have read it it is good

  6. Avatar
    Mens Watch over 2 years later:

    good.zf

  7. Avatar
    shopping over 2 years later:

    Moncler is the renowned high-end outerwear Discount Moncler brand which created a quilted jacket trend in the fashion world. Never one to stand still in time,It has always kept abreast of the latest Moncler Jackets technologies and stayed true to its origins without compromising its Moncler runway worthy style. If it has a Moncler tag, it will keep you warm on top of the highest mountain and be Moncler Men’s trendy on any city street.Features the latest selection of the north face clothing. You will enjoy what you Moncler Women’s show you. As well we offer you the good shopping experience with cheap and discount price.

  8. Avatar
    shopping over 2 years later:

    Hermes Birkin Handbags are fashion icons regarded Hermes Handbags as much more than simple purses. They are status symbols, with waitlists forcing fashion fans to wait more than Hermes Birkin two years to own one.Hermes Birkin Handbags were created by Hermes head Jean Louis Dumas and actress Jane Birkin. Word is that Jean wanted a functional weekend bag, and so the Birkin was born. Now these Hermes Belts prestigious bags are seen on the arms of all the hottest celebs including Hermes Purses Victoria Beckham, Sarah Jessica Parker, and Oprah Winfrey.

  9. Avatar
    shopping over 2 years later:

    Herve Leger Bandage High Waist Mini Skirts It is very eye-catching. You can wear Discount Herve Leger it in your casual time,go to office, go shopping, as you like in every place. As we know ,Herve Leger Dresses comes from French ,and found in 1985,it is the most famous designer house ,it always go in for the women’s beautiful shaped 90% Rayon, 9% Nylon,1% Spandex Zipper Herve Leger Dresses closure please just follow the show on the label to maintain the beauty Dry clean only These designer Herve Leger Bandage Dress and Herve Leger Skirts are feminine and sensual,stand out.

  10. Avatar
    shopping over 2 years later:

    There is a brand that continues to turn out the Hermes Birkin seasons to seasons, yes, there is Hermes Handbags. In this season, there is bright colors. The hermes birkin replica,Birkin HandBags,hermes birkin purses are all in our warehouse.The Replica Hermes Birkin makes an effort to please the all Hermes 35CM Birkin Bags request by the masses. When you first come across with the Replica Hermes Belts the showroom, you instantly think that it is a Replica Hermes Birkin you would love to tote.

  11. Avatar
    shopping over 2 years later:

    Beginning as a professional Cheap Moncler Coats seller, We achieved great success in this field. Moncler Giubbotti have a pretty good team who have been devoting themselves into reducing the costs by constantly Moncler Uomo looking for a best and steadiest manufacturer.By the year 2006, we had expanded our line from Moncler Gilet Donna to a wider range, They are Moncler Outlet,Moncler Boots,Moncler Scarf,Moncler Giubbotto Uomo. From Outletmoncler.com,People all over the world enjoy buying stuff and give high praises.

  12. Avatar
    shopping over 2 years later:

    To have the Hermes birkin bag is becoming every woman’s dream.Though they have a hilarious collections of Replica hermes birkin,and others feminine accessories,but only few women are able to obtain it,because Cheap hermes handbags of the price,Since that it designed by the would’s most known designer,then the price reaches more ther hundreds Hermes Belts dollars for an item. If you are in such problem,loving the handbags,but have limited fund that Hermes Purses are far away from it’s price,then Replica Hermes Bags would your best solution.

  13. Avatar
    Pandora over 2 years later:

    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.

  14. Avatar
    iPhone to Mac Transfer over 2 years later:

    I don’t know much about this topic. So, I am looking a way to solve it. I want to study. When I come to here, I think I am in the right place. the web gives me a lot of infomation, it is very informative. I think lots of people can learn much here. I will come to here again. Thanks.

  15. Avatar
    http://www.blacktowhiteiphone4.com over 2 years later:

    Bad news for folks who’ve been holding out for a white iPhone 4: Apple has delayed the white version of its popular smartphone until later this year. The white iPhone 4 was first delayed until late July, and then promised for the end of the month by Apple chief executive Steve Jobs just a week ago, but now there’s no ship date in sight.

  16. Avatar
    Dr Dre Headphones over 2 years later:

    With Monster Beats Studio, you’ll hear every sonic detail the musicians and recording engineers laid down in the studio. Deep bass. Hard hitting drums. Bold midrange. And clean, undistorted highs. All in a comfortable fit you can wear for hours. Solos are compact and incredibly lightweight and ready for your active lifestyle, gym work out, or frequent travel. The Monster Dr Dre Headphones design allows Solos to fit into the included compact carrying case. With Dr Dre Earphones getting a great music experience has never been easier. Now, a new headphone in the Beats tradition, Beats By Dr Dre in ear brings you amazing sound in a smaller, lighter on-ear design.

  17. Avatar
    dvdsoft over 2 years later:

    With the right tool, you can easily burn mp4 to dvd and itunes to dvd. Also, you can use drm removal tool to remove drm protection from itunes, zune, amazon legally. wmv to dvd, mov to dvd, mp4 to dvd, itunes to dvd

  18. Avatar
    http://www.blacktowhiteiphone4.com over 2 years later:

    Without the flash the white iPhone 4 is almost as bad as the 3G, but with a higher resolution. The worst phone in this test was the iPhone 3Gs with very bad low light performance.

  19. Avatar
    Multivariate Testing over 2 years later:

    This bauble source code sounds like a miracle. I’m constantly frustrated when standard coding practices hiccup and give me complications. I’m excited to install and try this out!

  20. Avatar
    US Criminal Record over 2 years later:

    Every run shows a different random scenario, so you can kill a lot of time by watching worlds in collision.

  21. Avatar
    hublot replicas over 2 years later:

    healing aspect of what rolex submariner replicas what happened—the tragedy,” said Lisa tag heuer replica Lisa Engelberg, a 30-year resident of Tucson.Engelberg fake burberry scarf Tucson.Engelberg added that

  22. Avatar
    iPad ePub Transfer for Mac over 2 years later:

    I really like this essay. Thank you for writing it so seriously. I want to recommend it for my friends strongly. An Professional transfer that can transfer the ePub books onto your iPad on Mac and export the iPad ePub to Mac local folder.

  23. Avatar
    iPhone contacts backup over 2 years later:

    Thanks for your information. It is wonderful. when you need, you can put your own iPhone contacts to computer hard drive and keep it safe. you know . the best way to protect your iPhone contacts.

  24. Avatar
    dvdsoft over 2 years later:

    With the right tool, you can easily burn mp4 to dvd and itunes to dvd. Also, you can use drm removal tool to remove drm protection from itunes, zune, amazon legally. wmv to dvd, mov to dvd, convert mp4 to dvd, itunes to dvd

  25. Avatar
    Tenant Screening over 2 years later:

    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.

  26. Avatar
    Criminal Records over 2 years later:

    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.

  27. Avatar
    iPad Video Converter for Mac over 3 years later:

    Thanks for your post, very informative.

  28. Avatar
    DRM Removal Software over 3 years later:

    It is a good post,I like it so much!

  29. Avatar
    okey oyunu oyna over 3 years later:

    good

    internette görüntülü olarak okey oyunu oyna, gerçek kisilerle tanis, turnuva heyecanini yasa.

  30. Avatar
    lose thigh over 3 years later:

    great baubles discussion…

  31. Avatar
    ray ban outlet over 3 years later:

    The good news is that our ray ban outlet store offer 50% discount on our ray ban online goods,and will give you the lowest price and the high quality fake ray ban sunglasses.

  32. Avatar
    Henry Jack over 3 years later:

    There is but one step from the sublime to the ridiculous. monster energy hats for sale dc hats wholesale

  33. Avatar
    beats by dre store over 3 years later:

    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.cheap beats by dre beats by dre store

  34. Avatar
    job description over 3 years later:

    I am glad Project Manager Job Description to see the great article in this blog that to Legal Secretary Job Description searching the amazing services in this blog Medical Transcriptionist Job Description This is very much happy for providing the great technology and reading the nice articles Paralegal Job Description in this website

  35. Avatar
    Fake Oakley Radar over 3 years later:

    It really a good article.Oakley Sport SunglassesOakley Jawbone SunglassesOakley Radar SunglassesOakley M Frame SunglassesFake Oakleys AAA Specials sunglassesFake Oakley Flak Jacket sunglassesFake Oakley Juliet sunglassesFake Oakley Half Jacket sunglassesReplica Oakleys Promotion SaleReplica Oakley Jawbone SunglassesReplica Oakley Oil Rig SunglassesReplica Oakley Polarized SunglassesFake Oakley BatwolfFake Oakley DangerousFake Oakley Dartcheap Oakley Antix SunglassesOakley Antix Sunglasses wholesalereplica Oakley Antix Sunglassescheap oakley batwolf sunglassesoakley batwolf sunglasses wholesalereplica oakley batwolf sunglasses

  36. Avatar
    Christian Louboutin over 3 years later:

    You can find now a few retailers such as BHS who sell a variety of page boy outfits including waist coat and suit. AdviceDinner-suit.co christian louboutin boots.uk have a guide toCheck out .

  37. Avatar
    ysbearing over 3 years later:

    Slewing ring is also called slewing bearing, some people called: rotary support, swing support. English Name: slewing bearing or slewing ring bearing or turn table bearing, slewing ring in the real industrial applications is very wide.

  38. Avatar
    christian louboutin over 3 years later:

    The professional design make you foot more comfortable. Even more tantalizing,this pattern make your legs look as long as you can,it will make you looked more attractive.Moveover,it has reasonable price.If you are a popular woman,do not miss it.

    Technical details of Christian Louboutin Velours Scrunch Suede Boots Coffee:

    Color: Coffee
    Material: Suede
    4(100mm) heel
    Signature red sole x

    Fashion, delicate, luxurious Christian louboutins shoes on sale, one of its series is Christian Louboutin Tall Boots, is urbanism collocation. This Christian louboutins shoes design makes people new and refreshing. Red soles shoes is personality, your charm will be wonderful performance.

  39. Avatar
    Wound Care over 3 years later:

    Excellent review!Very well written write-up. I love to blog but only on good subjects.I literally enjoyed the concept described in the post. Once again nice work indeed.

  40. Avatar
    ralph lauren over 3 years later:

    Siècle Série classique américain de los angeles marque Ralph Lauren hommes d’hiver communiqué de 2012, los angeles principale saison des longues de design guy cuir, créateurs intelligents ajouté fermeture éclair dans los angeles couche moyenne de cuir, veste durante cuir cuando longtemps devient instantanément courtroom. Los angeles couleur beige et noir également, put créer united nations design parfait guy scandinaves.http://www.vetementpoloralphlauren2012.net

  41. Avatar
    Backup iPhone SMS over 3 years later:

    I am glad that you can show us so professional article about programming. I think it is very useful for use to study here. So. why not try the way to improve ourselves and make a good code. Don’t waste everytime you get to run the application. thanks.

  42. Avatar
    Prada Sale over 4 years later:

    See you blog on yahoo.and I have searched this kinds of articles for days.Thanks for your nice great,I really like it.

  43. Avatar
    Prada Sale over 4 years later:

    See you blog on yahoo.and I have searched this kinds of articles for days.Thanks for your nice great,I really like it.

  44. Avatar
    Outlook Settings over 4 years later:

    In order to calculate the area and perimeter of an ellipse, you must first know the length of the ellipse’s semi-major axis and the length of the semi-minor axis.. Once you know these lengths, also sometimes referred to as the radii of the ellipse, you can calculate the area and perimeter with simple mathematical operations… Outlook Settings

  45. Avatar
    liudayun over 4 years later:

    I love this article, it’s very well.[url=http://www.sunglassbrand.com/oakley-sunglasses-oakley-commit-sq-sunglasses-c-18_64.html]replica Oakley Commit SQ Sunglasses[url][url=http://www.oakleyshub.com/oakley-gascan-sunglasses-c-1.html]Fake Oakley Gascan[url][url=http://www.sunglassbrand.com/oakley-sunglasses-oakley-split-jacket-sunglasses-c-18_46.html]Oakley Split

  46. Avatar
    Buy Power Tools over 4 years later:

    We will not gather this “hese are by far the most flattering g star raw , and this is true for all shapes Personalized stationery and sizes. “

  47. Avatar
    Makita Tool Parts over 4 years later:

    We are working on this occasion “They foresee a lot of things for you good a good plan, hope you less harm to hope you get the best, often only the other side misunderstanding, and even corporate web design tips disgust.”

  48. Avatar
    custom essays UK over 4 years later:

    This is same what I had been looking for long time. Finally I got it. Keep up your good work.

  49. Avatar
    low cost logo design over 4 years later:

    I read some of your post and I learned a lot of knowledge from it. Thanks for posting such interesting articles.

  50. Avatar
    abercrombie over 4 years later:

    Il était certainement intéressant pour moi de lire le blog. Merci pour elle. J’aime ces sujets et tout connecté à eux. Je voudrais en savoir plus bientôt.

Comments