[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] A project from the ground up



There's a lull in my attempt to bring a WASTE API to MacPerl, so:

Most of this is thinking in print, but just working it out in my head wasn't working.

It's not something I'm used to doing, building a project from the ground up.  In fact most of what I've done to date rather involves having had some ground work laid out ahead by someone else, and NOT having to start from nothing.  However, I have a particular itch that's needed scratching for some time now, and no real tools to scratch it with.

It started when I was playing the shareware game "Escape-Velocity."  Neat little game, nice architecture for developing plug-ins, but what really BUGGED me was the map.  CAN'T someone do a space-adventure game with ACCURATE starmaps? "Surely this would be fixable with a plug-in," I thought.

Well, it turns out to be too much work by hand in ResEdit.

First, one can have up to 1000 "s˙st" resources (that's an umlaut over the "y") describing solar systems with up to four spöb resources (planets/moons/space stations) and each linked to up to 16 of it's nearest neighbors.  To do any reasonable subset of the best available astrometric data, say:

Preliminary Version of the Third Catalogue of Nearby Stars
     GLIESE W., JAHREISS H.
    <Astron. Rechen-Institut, Heidelberg (1991)>

Avaliable from <http://www.adc.nasa.gov>

requires a non-trivial amount of data-processing before even beginning to write the output data into a resource file.  A program in C which I have, had some nasty bugs in it, which resulted in inaccurate output, and even after I somehow managed to track down the bugs, and recompile it for PPC, it still is FAR from giving it's output in a form I can actually USE.

The aforementioned Gliese & Jahreiss catalog (CNS3) consists of two files:  A README, which consists of a brief description of the catalog, and a byte-by-byte description of the second file "catalog"  The second file consists of 3803 undelimited records seperated by returns.

Okay, the trick is that the position data in CNS3 is standard astrometrics (Right Ascension, Declination and parallax), and the output I need is simple cartesian coordinates (Galaxy Centric, rather than Earth Centric (slightly more work)).  All the math is to be found at:

http://www.clark.net/pub/nyrath/starmap.html

High school trig, mostly (trouble is I didn't take trig until college, and then it was under the sorbiquet "Applied Trigonometry," as I was studying electronics at the time).

Now I note that the C code I have uses "typedef struct" to build the HUGE input array (LOADS of data in that input file, and sadly the C code throws most of it out).  How does one duplicate that in Perl?

So the trick I want to pull off is:

Take CNS3 as an input file

Perform the prerequisite transform from astrometric to cartesian positions for the 1000 nearest stars to a point "X, Y, Z", defined by the user.

Compute "connectedness" for each included star, where connected stars are the five closest neighbors regardless of actual distance. Cased on distance>3parsecs "unconnect" neighbors, and if all neighbors>3parsecs, leave only the closest.

Compute luminosity for each star (given is Visual Magnitude)

Based on luminosity, "guess" which stars have habitable planets (between .25 and 2 of Sol)

Exclude all but the "A" component of binaries (for mapping purposes we don't need duplicate locations).

Plot a map of included stars with connections in 2D by omitting the Z axis (for use as a reference). including indications of where habitable planets might be.

Create the appropriate "s˙st" resources with X,Y and connection data.

Optional: Generate "spöb" resources for each "s˙st", placing habitable planets only where possible, and scattering uninhabited planets and spacestations at random.

WAY Optional: use the Hipparcos catalog as input rather than CNS.  Hipparcos is HUGE, over 100,000 records (approx 100Meg), super accurate (but oddly MORE accurate with distance -- sadly misses most of the dimmer stars (dim because their not very luminous, not because of distance -- Many nearby stars are missing from Hipparcos because they're less than magnitude 13))

Whew!

Goal:  Do the above in MacPerl.

Things I need:

Help with math functions in Perl.

Advice on ways to generalize the code so that it'll be useful beyond the scope of my immediate needs

Support, encouragement, and better yet, collaborators.

Since the bulk of this is off-topic for practically EVERY MacPerl list, I'd like to direct those interested in helping to a more appropriate forum.  Lucky for me I don't have to create one from scratch.  There's already:

Starmap_List@mpower.personalexpressions.com

Oh, did I mention I used to moderate over there?  Anywhy, I'd be please as punch if a bunch of MacPerlers descended upon the above list and began discussing hacking the CNS data.  Of late it's been dominated by the WinDoze crowd, where there's a multiplicity of incompatible programs for doing this stuff.

To prevent further off-topic discussion, follow-ups should go off-list, and when I have something meaningful to report I'll come back.

--B

# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
#
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org