In his TV series “Cosmos”, Carl Sagan travels the universe in a “ship of the imagination”. Uninfluenced by the laws of physics, “perfect as a snowflake, organic as a dandelion seed”, this vessel carries him between galaxies, stars, and planets. And now you can cruise the cosmos too!
Recently I watched cosmos again and remembered how that sequence fascinated me as kid.
The sheer scale of the distances involved blew my mind. It still does today. The concept has been revisited by many popular movies and media (Man in Black, The Simpsons…) and is always the same – the camera enters the universe, our galaxy, solar system and finally stops on earth – sometimes entering the microcosm, like the DNA of a cell. Years ago I experimented with something like a pyramidial image to archive this effect in flash, unfortunately the result didn′t create the feeling of depth that I had hoped for. But flash has advanced in those years… as I wrote before, in the strange attractor post, Ralph Hauwert and Joa Ebert have published some astonishing code that renders nearly half a million particles in real-time! First I decided that I would work with real data – otherwise this would become just another “random stars / noise flying at you” screensaver. But after some research I learned that the actual distance of nearby stars (called “stellar parallax”) is not always known, so that most models and databases project stars onto the inside of a virtual sphere. Finally I found the HYG database – “a subset of the data in three major catalogs: the Hipparcos Catalog,the Yale Bright Star Catalog (5th Edition), and the Gliese Catalog of Nearby Stars (3rd Edition)”.
It contains about 120.000 stars, many including their parallaxes and conveniently cartesian coordinates, so I saved the step of calculating xyz from right ascension, declination and distance – like I had to with other databases I tested. The CSV file got stripped of all additional data aside from the positions with a simple parser – that got it down from 20 to 4MB – still too big for my taste. So I added the Fzip library to Joa′s AS3 only version of Ralph′s experiment, parsed the position vectors, scaled them and got my first view on our galaxy – breathtaking. Scaling, controls and a simple clipping where swiftly implemented and everything was set for the voyage to the stars…
Tribute – “A Glorious Dawn” displacedWhile watching the result, an idea struck my mind:
As the z-axis movement of the camera or the zooming into the szene is done by simply scaling the particle positions, its obviously possible to change their parameters in realtime… I remembered my displacement experiment with papervision and quickly added a color parameter to the particle class, loaded an flv video and compiled this:
ConclusionIt′s possible to handle an awful lot of particles with flash, even more if haxe/alchemy – inlining gets involved.
As the displacement experiment shows, the dataset can even be dynamic! And hey – these are real stars, so this is science!
Hint: turn up your gamma adjustment.
|
Comment :2