calculate distance between planets?

General discussion for players of Oolite.

Moderators: winston, another_commander

lfnfan
Deadly
Deadly
Posts: 250
Joined: Tue Mar 24, 2009 1:29 pm
Location: london, uk

calculate distance between planets?

Post by lfnfan »

Hello. I just came upon Oolite yesterday - fantastic fantastic.

I have the Oolite_galaxies spreadsheet. Is it possible to use the X and Y vectors supplied in that spreadsheet to calculate the actual light year distance between two planets in the same galaxy?

Any advice much appreciated
Last edited by lfnfan on Wed Mar 25, 2009 1:58 pm, edited 1 time in total.
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6885
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Post by Disembodied »

It should be ... although doing so would involve some sort of sum, or similar trick with numbers, I would imagine. Not my strong point! :oops:

Of course, the distance as the hyperspatial crow flies isn't necessarily the same thing as the actual distance a player would have to travel, since players can only make hops of up to 7 light years each time.

PS: welcome to the boards!
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

The chart co-ordinates aren't in light years, so it won't be a simple application of Pythagorus' Theorem if that's what you were hoping.

For example the distance between Qubeen (planet 233) and Soladies (planet 248) is 7.2ly (as seen in the Long Way Around mission). Qubeen is at [132, 243] and Soladies at [112, 252]. By Pythagorus it would be sqrt((132-112)^2 + (243-252)^2)) or something like 22.1 in whatever units the chart co-ords are in.
lfnfan
Deadly
Deadly
Posts: 250
Joined: Tue Mar 24, 2009 1:29 pm
Location: london, uk

Post by lfnfan »

thanks for the welcome!

yep - cartesian stylee. I just tried lave to riedquat, which, from what I remember, is about 7 light years (just at the edge of one tank of fuel)

lave 20,273
riedquat 3,181

Carol Vorderman told me the cartesian equation is :
root((x2-x1)^2 + (y2-y1)^2)

which gives: ( 289 + 64 ) ^0.5

which gives: 19

which is not at all near 7.

lave to zaonce on the same basis comes out at 17.5, but it should also be about 7.

Rats. I'm trying to work out some good trading routes, and being able to compute these distances would really help :?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

I'm not Carol Vorderman. We've just got the same IQ ;)
lfnfan
Deadly
Deadly
Posts: 250
Joined: Tue Mar 24, 2009 1:29 pm
Location: london, uk

Post by lfnfan »

lol. I'm not Carol Vorderman either, we've just got the same legs :shock:


do you think there's a conversion factor applied to get to the light years measurement?

Or there's a big ol' matrix of planetary distances stored somewhere (which would seem like a lot of work)....

??
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6885
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Post by Disembodied »

... my cat's breath smells of cat food.

On a more helpful note, have you tried Presti's excellent star map of Galaxy 1?

Image
User avatar
Gimi
---- E L I T E ----
---- E L I T E ----
Posts: 2073
Joined: Tue Aug 29, 2006 5:02 pm
Location: Norway

Post by Gimi »

lfnfan wrote:
yep - cartesian stylee. I just tried lave to riedquat, which, from what I remember, is about 7 light years (just at the edge of one tank of fuel)

lave 20,273
riedquat 3,181

Carol Vorderman told me the cartesian equation is :
root((x2-x1)^2 + (y2-y1)^2)

which gives: ( 289 + 64 ) ^0.5

which gives: 19

which is not at all near 7.

lave to zaonce on the same basis comes out at 17.5, but it should also be about 7.

Rats. I'm trying to work out some good trading routes, and being able to compute these distances would really help :?
Anybody tried to see what happens if you use parsecs. I know that in this case it makes it worse, but there are other units used for measureing astronomical distances. AU (Astronomical Unit) is another one. If your 19 distance = 19 "desiparsecs", you would get about 6.2 LY. Just a thought that some other unit might have been used.

Wikipedia:
The parsec ("parallax of one arcsecond", symbol pc) is a unit of length, equal to just under 31 trillion kilometres (about 19 trillion miles), or about 3.26 light-years.

An astronomical unit (abbreviated as AU, au, a.u., or sometimes ua) is a unit of length based on the mean distance from the Earth to the Sun. The precise value of the AU is currently accepted as 149,597,870,691 ± 6 metres[1] (nearly 150 million kilometres or 93 million miles).

And if you look here

http://en.wikipedia.org/wiki/Conversion_of_units#Length you will find a few more unit types for measuring huge distances.

However, if those coordinates are from the original Elite, I suspect that they were chosen, and used because they fit and saved memory and do not represent any unit at all.
"A brilliant game of blasting and trading... Truly a mega-game... The game of a lifetime."
(Gold Medal Award, Zzap!64 May 1985).
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6885
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Post by Disembodied »

Could you not just take whatever the game shows the distance as being between Lave and Riedquat (say, 6.8 LY) and divide that by whatever number you get from your calculation (19), giving 0.358 or thereabouts. So – assuming that I understand this, which is by no means a given – if you then multiply all your answers from Carol Vorderman's equations by 0.358, you'll get the answer in light-years. Yes? Or no?
lfnfan
Deadly
Deadly
Posts: 250
Joined: Tue Mar 24, 2009 1:29 pm
Location: london, uk

Post by lfnfan »

Disembodied, that is exactly what I was thinking!! I will calculate a few more distances when I get back to the game, and see if there is a constant 'x-factor' (shudder)....

Would be neat if that factor also translated into an actual astronomical measure (there seem to be a few to choose from :)
)
That trading starmap is an awesome piece of work - thanks for pointing it out.
User avatar
tomsk
Dangerous
Dangerous
Posts: 66
Joined: Sun Jan 11, 2009 12:21 pm
Location: under my Cobra's hood...

Post by tomsk »

Here's what I worked out

Distance = INT(SQRT(INT(ABS(x_dest - x_start))^2+INT(INT(ABS(y_dest - y_start))/2)^2))*0.4

x_start, y_start : x, y co-ords of start planet
x_dest, y_dest : x, y co-ords of destination planet
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

lfnfan wrote:
Rats. I'm trying to work out some good trading routes, and being able to compute these distances would really help :?
I am sure your approach is right. It only needs an appropriate scaling factor.

Wait.... searching in the code: Hmm. It is a bit different. From the code I read:

Code: Select all

OOINLINE double distanceBetweenPlanetPositions ( int x1, int y1, int x2, int y2)
{
	int dx = x1 - x2;
	int dy = (y1 - y2)/2;
	int dist = sqrtf(dx*dx + dy*dy);
	return 0.4 * dist;
}
It seems that the y-axes is scaled differently. And take note it works with integers, so you get rounding errors!

However, for trading routes you don't need LY but flight time. And flight time in hours is the square of jump distance in LY. This non-linear flight time complicates things. Doing two smaller jumps is much faster in game time than one big jump. (In playing time it is the opposite of cause).

For calculating efficient trading routes you must divide the distance in as much short jumps as you can.

EDIT: And that is what Tomsk wrote above.
User avatar
ClymAngus
---- E L I T E ----
---- E L I T E ----
Posts: 2514
Joined: Tue Jul 08, 2008 12:31 am
Location: London England
Contact:

Post by ClymAngus »

Does this mean someones going to have to do the rounds and fill in each line as a hyper link? S*D that, I'll see if I can hack it out of the code.
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Welcome to the board!
lfnfan wrote:
Rats. I'm trying to work out some good trading routes, and being able to compute these distances would really help :?
Maybe you should try to get the advanced navigational array and use that one, as it calculates the real routes a player would have to fly from one planet to another, even with any number of jumps in between!

Screet
lfnfan
Deadly
Deadly
Posts: 250
Joined: Tue Mar 24, 2009 1:29 pm
Location: london, uk

Post by lfnfan »

wow, thanks for your responses people. that's very cool.

Tomsk and Eric - thanks for the formula and the proof in the code!

Screet - I've already spotted the Advanced Navigational Array - now I just need to start earning some credits!!

Eric - what's the game time consideration with long jumps? I would rather do one long jump than two short ones 'cos it means less chance of ending up on the side of a space station :oops:
Post Reply