Monday 16 December 2019

Tales of Known Space

Early on in my writing career, and inspired by the likes of Larry Niven and others, I began to make up invented planets and locations around actual stars in our neighborhood of the galaxy. Since my stories were based around the idea of slower-than-light travel, I did what everyone else did at the time: looked up a list of moderately nearby stars and cherry-picked the ones I wanted for my fictional universe. It's for this reason that Chasm City is on a planet orbiting Epsilon Eridani, which is a bit smaller and cooler (and younger) than our own star, but still suitable enough for science fictional purposes.

It's quite a fun game, and one can easily spend a lot of time making up the names and attributes of these hypothetical worlds. Niven did just that with his Known Space stories, in which many of the planets had outlandish characteristics, such as very high gravity (Jinx) or an extremely dense atmosphere (Mount Lookitthat). In the early eighties, when I started writing in earnest, there were no real constraints on what such alien solar systems might look like. We had detected no planets around other stars, and the general view was that such work was far beyond the current capabilities of astronomers. It turned out not to be the case, though: detecting alien planets, although difficult, required only a clever upgrading of existing methodologies. By the nineties, planets were being discovered with some regularity, and we now know of thousands of them, including many cases of multiple planets around the same star. In some instances, our observations have begun to put limits on the numbers and properties of planets around familiar, SF-friendly stars such as Epsilon Eridani. It may well turn out that what was perfectly reasonable speculation thirty years ago is now ruled out by current data.

Still, let's assume for now that our real stars and imagined planets remain viable locations, and we wish to use them in new stories. That's where an additional wrinkle comes in: it's very easy to look up how far away these stars are, and on that basis, work out (depending on the mechanics of your imagined space technology) how long it would take to get there from Earth. But sooner or later your story may depend on getting from star A to star B, without stopping off at Earth en-route. How do we work out how far these stars are from each other?

All the information we need is present: for any given star, all we need are its coordinates in the night sky, and a figure for its distance. In the case of stars, those coordinates are given in somewhat unfamiliar terms: Right Ascension and Declination. Beneath the terminology, though, lies a very simple and intuitive idea. Think of a tank (or a Dalek, if so preferred). The tank can swivel its turret through a circle (or the Dalek can spin on its base), and it can raise and lower its gun barrel (or eye-stalk). The Right Ascension is the amount of swivel, and the Declination is the amount of elevation of the barrel. With those two numbers (and assuming that the barrel can point down as well as up) there's no part of the sky that the tank can't aim at. That gives you a direction to point in, and the distance tells you how far along that line that star lies. At which point, the star's position is determined in three-dimensional space. This is a spherical coordinate system, though, and (certainly for me) if I'm going to calculate the distance between two points, I'd far rather do so in the familiar Cartesian space of x, y and z.

Fortunately, we can easily convert from spherical to x,y,z coordinates, using some simple trigonometric relations. For a pair of stars, we can work out their individual positions and then use Pythagoras to work out the distance between them. It's fiddly and time-consuming, though, and far better done with a small computer program.

I wrote such a program a long, long time ago, back when I was a working scientist and wrote software (in Fortran, C or Perl) almost every day. and almost always in a Unix environment. I left science in 2004, however, and since then I have written exactly one program: an incredibly simple Arduino script to make the navigation lights on my Starship Enterprise flash on and off. Not only do I not have the old program for stellar distances, I wouldn't know what to do with it if I did. My working environment now is exclusively Windows, not Unix.

I was pleased, therefore, to find that I could still write, compile and run a Fortran program on my laptop. I downloaded the Simply Fortran package from Approximatrix and found that, allowing for my rustiness, I was still able to cobble together what I needed within a few hours of head-scratching.

I wrote a simple program called "Stars" which takes the Right Ascension, Declination and distance of any given pair of objects and outputs the distance between them in light years. There's nothing at all clever about it but there's still plenty of room for error: just because a program compiles and executes doesn't mean it's giving you sensible results. Back in my science days we'd always talk about "sanity checks": putting inputs into programs which ought to give predictable results; the kinds of special cases that you can check for yourself in your head or with simple pen and paper calculation.

One such case is easy: put one of the star's distances in as zero. You are essentially defining it as the Sun (the RA and Dec don't matter) and any outputted distance for the pair of stars ought to be the canonical distance to the other one of your objects. This all checked out. I also did some simple tests where the test-case stars were symmetrically opposed so that the distances could be calculated using simple trigonometric rules - again, all looked good. I also double-checked some of the distances as given in the later Revelation Space books, and found that all looked sensible. But I still wasn't intuitively satisfied that my program was running correctly, and decided a further check was needed.

Here we turn to the exciting world of cardboard and glue, and I made a simple model:

The circular bit is the Right Ascension plane, subdivided into ten degree quadrants. I marked out three radial distances at 5, 10 and 15 light years, on a scale of 1cm per light year.

The apexes of the four triangles - three big ones and one very long, low one - mark the positions of individual stars. These were made using a protractor and ruler, using the declination and distance values, and then glued in place at the appropriate relative positions using the RA value. For the sake of construction these stars are all in the northern hemisphere, but if their declinations were negative, they would simply project below the circle. Since the ruling scale is 1cm per light year, the distances between any two stars can now be estimated simply by holding a ruler between two apexes, and a "sanity check" made on the program. I was pleased to see that the outputted results all agreed with the ruler, to within about half a cm - consistent with the tolerances of my model, cardboard not being known for its precision engineering properties.

While it would be very nice to check the case of the distance between two real stars with positive and negative declinations, I'd need to punch a hole in the RA plane to do that. However, at this point I have enough confidence to trust that my program is behaving sensibly.


  1. Hmm, now I want to write a version of this that takes star names/designations as input, queries Simbad for RA/Dec and parallax, and then calculates the distance.

  2. That would be neat. Simbad, now there's a blast from the past...

  3. I wonder how accurate the stellar forge in Elite:Dangerous is?

    1. They used NASA data to generate stars that we do and don't know about. So all the stars that we know about you can go and visit and they're all accurate down to the mass and temperature. Even the exoplanets too.

  4. I wouldn't know - I've never played it or seen it.

    If it just generates random stars and positions, that should be fine for a game provided it isn't pretending they relate to real ones. One of the attractions of doing the Merlin stories (and others) was precisely not having do to this sort of calculation.

  5. I know it's a bad habit, but I always used Excel for this (not always, it was Lotus 1-2-3 originally). My data source was Gliese catalogue data someone kindly put up on the Internet for download by ftp.

    Nowadays I'd use I'm using it at the moment (Excel again!) but strictly for mass, radius, bulk density and temperature, no consideration for now of how far they all are from each other.

  6. Honestly, these days it takes real courage to set your sci-fi stories within the light-speed limit.

    Well done, Alastair.

  7. I really enjoyed reading this article; it set things out for me in an understandable manner and I liked the model you built to illustrate. I enjoy your novels and have been a sci-fi fan for over 50 years. And I really geek the Nostromo. I posted on my site about this article of yours to share with my readers. Cheers!

  8. Thanks! I wish I had known that there were widgets out there to do those calculations.