Page 1 of 2

calculate distance between planets?

Posted: Tue Mar 24, 2009 1:34 pm
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

Posted: Tue Mar 24, 2009 1:43 pm
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!

Posted: Tue Mar 24, 2009 2:00 pm
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.

Posted: Tue Mar 24, 2009 2:35 pm
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 :?

Posted: Tue Mar 24, 2009 2:50 pm
by Thargoid
I'm not Carol Vorderman. We've just got the same IQ ;)

Posted: Tue Mar 24, 2009 2:55 pm
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)....

??

Posted: Tue Mar 24, 2009 2:57 pm
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

Posted: Tue Mar 24, 2009 2:59 pm
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.

Posted: Tue Mar 24, 2009 3:06 pm
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?

Posted: Tue Mar 24, 2009 3:23 pm
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.

Posted: Tue Mar 24, 2009 3:24 pm
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

Posted: Tue Mar 24, 2009 3:35 pm
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.

Posted: Tue Mar 24, 2009 3:54 pm
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.

Posted: Tue Mar 24, 2009 4:06 pm
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

Posted: Tue Mar 24, 2009 4:33 pm
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: