Sign in to follow this  
matt3d

Representing Large Distances (Light years)

Recommended Posts

Simple question really, I am wondering how programs like Celestia can represent such large distances (say 1000 light years is the distance across the Milky Way galaxy).

Share this post


Link to post
Share on other sites
If your base unit of measurement is 1 meter, then a 64 bit number actually has [i]just [/i]enough precision to store 1000 light-years ;)

I'm guessing though that they wouldn't use absolute positions - locations could be describe as a relative offset from a parent coordinate system.

e.g. the centre of a solar system could be quantised to the nearest million kilometers (and stored in a format where "1" represents 1M km), then planets could describe their position relative to the solar system, etc...

Share this post


Link to post
Share on other sites
Scientific programs have support for big numbers which are arbitrary precision floating point numbers.. So the coordinates are probably stored in that which isn't limited by the machines integral types..

Share this post


Link to post
Share on other sites
You can also use one value to represent large units, and a second one to represent small units. For example, use a long to store the light year position, and a double for the fraction part. Its the same way you keep track of years, days, hours, etc. though for a bit different reason.

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1297996526' post='4775674']
If your base unit of measurement is 1 meter, then a 64 bit number actually has [i]just [/i]enough precision to store 1000 light-years ;)
[/quote]

It is my understanding that the values become imprecise the larger the value gets though?

Share this post


Link to post
Share on other sites
[quote name='matt3d' timestamp='1298034536' post='4775836']
[quote name='Hodgman' timestamp='1297996526' post='4775674']
If your base unit of measurement is 1 meter, then a 64 bit number actually has [i]just [/i]enough precision to store 1000 light-years ;)
[/quote]

It is my understanding that the values become imprecise the larger the value gets though?
[/quote]

That is true for floating point numbers, but I believe he was referring to using an integer. Those have exactly the same resolution for their entire range.

Share this post


Link to post
Share on other sites
I'm doing this in my Galaxy Space Trade Simulator by using 3 different data types.

[list=1][*]Lightyears - Holds the value in lightyears for where the star is located. This is just a floating point number between 0.01 and 1020.01[*]AU - This is the distance of the planet from the star. 1 AU = 149597870.7 km (distance from sun to earth). This is also a floating point value.[*]Km - This is then used to describe objects/planets/ships etc that are closer than 1 AU. I use a floating point number for this too. Actually it only kicks in when under about 0.8 AU because the system I am using cannot reliably represent floating point numbers above 128 million. But the system works brilliantly for me and besides who wants to know that a star is 74,634,389,340,823,489,023,423 km away. The mind cant crasp that. It is much easier to see that something is 13 Lightyears away :)[/list]

Share this post


Link to post
Share on other sites
In principle there is no good reason to have more resolution near the origin than anywhere else, so it makes sense to use fixed-point numbers. You can represent the whole galaxy in femtometers with 128-bit integers, which are easy to implement as two-digit numbers in base 2^64. To make things more human friendly you can use a 64+64 fixed-point representation, where the units are Kilometers.

You may find [url="http://www2.pvc.maricopa.edu/tutor/chem/chem151/metric/magnitude.html"]this table[/url] useful.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this