Celestia coordinates and Elite Dangerous

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Redden Alt-Mer
Posts: 6
Joined: 17.12.2017
With us: 6 years 11 months

Celestia coordinates and Elite Dangerous

Post #1by Redden Alt-Mer » 17.12.2017, 17:48

Hi everyone,

let's start with a disclaimer: I'm new to Celestia and I have close to zero
education in Astrophysics, so the following post may be full of dumb
stuff.

The problem I'm trying to solve is pretty straightforward: sometimes, when
playing Elite Dangerous, an online space simulator set in 3303 in an "as
faithful as possible" representation of our galaxy, you find yourself in need
of trying to map a particular set of stars you see in the skybox to their
names. Unfortunately, the in-game galaxy map of Elite Dangerous is as awkward
as it gets and there's no other way of identifying a star (no click, no
targeting, nothing). Elite Dangerous star map uses rectangular coordinates for
Stars, where x,y,z are expressed in light years from Sol (0, 0, 0).

A potential solution to this problem, at least for catalog stars, is to use
Celestia, place yourself roughly in a position that shows the same stars you're
looking for in Elite Dangerous, and get their names from Celestia. So far so
good, but Celestia does not seem to offer ways of getting the coordinates of
the observer position through the GUI. This problem can be easily solved by
taking the names of the identified stars and their distances from the observer
from Celestia, get the position of those stars in Elite Dangerous, and
trilaterate. I've used this method in a couple of cases successfully, being
able to correctly map Celestia observer position to a position inside Elite
from where the desired stars could be observed in the same configuration.

The problem of this approach is that it is a bit cumbersome and error-prone,
thus being able to get the observer coordinates from Celestia directly would be
much more direct and comfortable. Luckily, this is doable pretty easily with
the following CELX script (note the date is set to Elite Dangerous current
date):

Code: Select all

getObserverPosition= function()
  tdb_dt = celestia:utctotdb(3303, 12, 15, 00, 00, 00)
  celestia:settime(tdb_dt)

  obs = celestia:getobserver()
  obsPos = obs:getposition()

  celestia:print("Position:\nX = " .. obsPos.x/1e6 ..
                 "\nY = " .. obsPos.y/1e6 .. "\nZ = " ..  obsPos.z/1e6,
                 15, -1, -1, 1, 6)
end


Placing myself around Merope, the script above returns the following
coordinates:

Code: Select all

X = 191.342
Y = 26.226
Z = -327.43


The same result is consistently obtained by directly querying Merope position,
or calculating an heliovector between Sol and Merope:

Code: Select all

  tdb_dt = celestia:utctotdb(3303, 12, 15, 00, 00, 00)

  sol = celestia:find("Sol")
  solPos = sol:getposition(tdb_dt)

  merope = celestia:find("Merope")
  meropePos = merope:getposition(tdb_dt)

  heliovector = solPos:vectorto(meropePos)



So far so good, right? No. The real problem appears (finally!) when comparing
Merope's position in Celestia with the one in Elite Dangerous, which pretty
much have nothing to do with each other, except for the Z-axis:

Code: Select all

x=-78.59375
y=-149.625
z=-340.53125


At first I thougth of an error in Elite Dangerous galaxy, but all the other
star positions I tested, close to Merope or close to Sol, have the same
inconsistencies.

In order to further exclude discrepancies, I then calculated the distances
between these systems and Sol, both in Celestia and in Elite Dangerous. For
example, with Merope:

Code: Select all

  sol = celestia:find("Sol")
  solPos = sol:getposition(tdb_dt)

  merope = celestia:find("Merope")
  meropePos = merope:getposition(tdb_dt)

  celestia:print("Distance (Ly): " .. solPos:distanceto(meropePos)*1.057e-13,
                 15, -1, -1, 1, 6 )



I get 380.14Ly. In Elite Dangerous, the distance between Sol and Merope is roughly the same:

Code: Select all

Sol: System(x=0, y=0, z=0)
Merope: System(x=-78.59375, y=-149.625, z=-340.53125)
Distance between Sol and Merope: 380.17Ly


Distances match for other stars too, and also when using different source
systems, e.g., the distance between Aldebaran and Merope is 315.82Ly in
Celestia and 315.84Ly in Elite Dangerous.

At this point I'm pretty much lost. It appears that Celestia and Elite
Dangerous stars are placed consistently, but in different positions.

Going through the documentation, I found this line, relative to method
object:getposition:

Celestia's native coordinate system is based on the J2000 ecliptic, but it's rotated by 90 degrees from the conventional definition.
(https://en.wikibooks.org/wiki/Celestia/Celx_Scrip ... ethods/Celx_object#getposition)

Shortly after, the same page mentions this snippet of code:

Code: Select all

   -- Convert from Celestia's internal coordinate system
   return celestia:newvector(v.x, -v.z, v.y)


I promptly tried it, but as you can see, it just inverts two coordinates, so
the following snippet of code:

Code: Select all

  tdb_dt = celestia:utctotdb(3303, 12, 15, 00, 00, 00)

  sol = celestia:find("Sol")
  solPos = sol:getposition(tdb_dt)

  merope = celestia:find("Merope")
  meropePos = merope:getposition(tdb_dt)

  heliovector = solPos:vectorto(meropePos)

  newHeliovector = convert(heliovector)



returns:

Code: Select all

X = 191.342
Y = 327.43
Z = 26.226


I also tried more complex rotations, such as what I hope is a 270 degree
rotation over Z-axis (which seems the closer one to Elite) to match the 90 deg
rotation mentioned in the above method's documentation:

Code: Select all

  tdb_dt = celestia:utctotdb(3303, 12, 15, 00, 00, 00)

  sol = celestia:find("Sol")
  solPos = sol:getposition(tdb_dt)

  merope = celestia:find("Merope")
  meropePos = merope:getposition(tdb_dt)

  heliovector = solPos:vectorto(meropePos)

  -- Rotate 270 to match a 90 rotation
  up_v = celestia:newvector(0,0,1.5)
  minusNinety = celestia:newrotation(up_v, math.pi)
  newHeliovector = minusNinety:transform(heliovector)


to no avail, this completely messes the coordinates. I also tried different
rotations, e.g., -0.5 (i.e., -90deg?), 1.5 on each axis, etc.

Finally, I tried what seemed the simplest solution: changing the frame of
reference, using "ecliptic" centered on Sol and "universal":

Code: Select all

getPositionFrame= function()
  tdb_dt = celestia:utctotdb(3303, 12, 15, 00, 00, 00)

  sol = celestia:find("Sol")
  solPos = sol:getposition(tdb_dt)

  merope = celestia:find("Merope")
  meropePos = merope:getposition(tdb_dt)

  -- frame = celestia:newframe("universal")
  frame = celestia:newframe("ecliptic", sol)
  obsPos = frame:to(meropePos)

  celestia:print("Position:\nX = " .. obsPos.x/1e6 ..
                 "\nY = " .. obsPos.y/1e6 .. "\nZ = " ..  obsPos.z/1e6,
                 15, -1, -1, 1, 6)
end


But this always returns the same positon.

So, at this point I pretty much ran out of ideas and was suggested to post
here. Any help would be greatly appreciated and, again, sorry for any obvious
mistake due to my inexperience with coordinates systems.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #2by selden » 19.12.2017, 11:43

I seem to recall that you have to swap two of the axes in addition to negating one of them. Something like this, perhaps?

Code: Select all

   x0 =  y1
   y0 = -z1
   z0 =  x1
Selden

Topic author
Redden Alt-Mer
Posts: 6
Joined: 17.12.2017
With us: 6 years 11 months

Post #3by Redden Alt-Mer » 19.12.2017, 16:04

Hi Selden, thanks for your reply!

Unfortunately, I tried this already (see at about half of the post, when talking about the object:getposition documentation) but it didn't help!

Topic author
Redden Alt-Mer
Posts: 6
Joined: 17.12.2017
With us: 6 years 11 months

Post #4by Redden Alt-Mer » 20.12.2017, 14:13

To help the discussion a bit, here's a partly interactive representation of Elite dangerous galaxy: https://www.edsm.net/en/galactic-mapping#2/0/0/25000

The three axis are as follows:
z: goes from Sol towards Sag A* (x=25.21875, y=-20.90625, z=25899.96875)
x: perpendicular to z, increases going "right of" Sag A*
y: perpendicular to the galactic plane

Shadimius
Posts: 7
Joined: 21.12.2017
With us: 6 years 10 months

Post #5by Shadimius » 21.12.2017, 18:19

This sounds fun. I have a little experience with Elite Dangerous and a bit more trying to figure out Celestia's coordinate system ;P (So glad the forum is up now!)

Anyway, how do you go about getting the coordinates in the game? Could you post the coordinates of say 8 stars on different sides of the galaxy, in both Celestia and Elite Dangerous terms? Maybe looking at all those together could help someone decipher a relationship (I'm hesitant to say it would be me, but I'm curious to take a gander :biggrin: )

Cheers

Shadimius
Posts: 7
Joined: 21.12.2017
With us: 6 years 10 months

Post #6by Shadimius » 22.12.2017, 00:36

edit: double post
Last edited by Shadimius on 22.12.2017, 16:56, edited 1 time in total.

Topic author
Redden Alt-Mer
Posts: 6
Joined: 17.12.2017
With us: 6 years 11 months

Post #7by Redden Alt-Mer » 22.12.2017, 13:04

Ehy, sure!

Elite dangerous has coordinates saved in a logfile when you jump to a system, and there's EDSM (the website I linked a post ago) that basically collects as many as possible and offers an API to retrieve them programmatically. So, for example, given a system name you could query EDSM like this:

https://www.edsm.net/api-v1/system?systemName=Merope&coords=1

I will later try to find some stars that match your criteria, if you have any suggestions for star names that are mapped inside Celestia they'd be very welcome, I'll try to get the equivalent in Elite Dangerous and retrieve coordinates in both systems.

Shadimius
Posts: 7
Joined: 21.12.2017
With us: 6 years 10 months

Post #8by Shadimius » 22.12.2017, 19:26

I decided to check it out, and repurposed an old script I've been revisiting. I popped in some star systems from my 'names of star systems' google search, then did the same in the EDSM query, found below.

Honestly I thought this might help but it's definitely confusing me more right now. Or theres no pattern. Or - I don't know. But here's some data. Gotta take a break for now but I'll go ahead and post that:

Code: Select all

"Sirius"                          sirius
x    6.25                          sirius x = -1.6089185476303
y    -1.28125                      sirius y = -5.471616268158
z    -5.75                          sirius z = -6.4141006469727

"Mira"                               Mira
x    -45.375                      Mira x = 245.0517578125
y    -352.78125                      Mira y = -82.085647583008
z    -220.9375                      Mira z = -150.29823303223

"Procyon"                           procion
x    6.21875                      procion x = -4.7676010131836
y    2.65625                      procion y = -3.1460378170013
z    -9.1875                      procion z = -9.86803150177

"Merope"                           merope
x    -78.59375                      x = 191.34243774414
y    -149.625                      y = 26.226203918457
z    -340.53125                      z = -327.43362426758

"Alpha Centauri"                   alpha                     
x    3.03125                      alpha x = -1.6318907737732
y    -0.09375                      alpha y = -2.9543473720551
z    3.15625                      alpha z = 2.7680294513702

"Fomalhaut"                       fomalhaut             
x    -3.78125                      fomalhaut x = 21.039205551147
y    -22.875                      fomalhaut y = -9.0597429275513
z    9.6875                          fomalhaut z = 10.325380325317

Topic author
Redden Alt-Mer
Posts: 6
Joined: 17.12.2017
With us: 6 years 11 months

Post #9by Redden Alt-Mer » 22.12.2017, 20:51

Thanks for extracting the data, I'm sorry to hear that's confusing for you too :/ I calculated some more distances and it seems that the stars, despite having completely different coordinates, are placed in the same way wrt each other. So, with the single exception of Mira, all have the same distance from Sol:

Code: Select all

ED: Sol -> Sirius: 8.5887
CEL: Sol -> Sirius: 8.5830

ED: Sol -> Mira: 418.7205
CEL: Sol -> Mira: 298.9615

ED: Sol -> Procyon: 11.4078
CEL: Sol -> Procyon: 11.4020

ED: Sol -> Merope: 380.1660
CEL: Sol -> Merope: 380.1480

ED: Sol -> Alpha_Centauri: 4.3771
CEL: Sol -> Alpha_Centauri: 4.3650

ED: Sol -> Fomalhaut: 25.1279
CEL: Sol -> Fomalhaut: 25.1265


And also between each other:

Code: Select all

ED: Sirius -> Merope: 375.8761
CEL: Sirius -> Merope: 375.8836

ED: Fomalhaut -> Merope: 379.8890
CEL: Fomalhaut -> Merope: 379.9071


So, I'd say that with the exception of Mira, stars in E:D seems to be placed consistently, yet with its own reference frame. Now, what transformation (rotation?) can lead from one to the other is beyond my math powers.

Shadimius
Posts: 7
Joined: 21.12.2017
With us: 6 years 10 months

Post #10by Shadimius » 23.12.2017, 18:58

Interesting. Perhaps finding a sequence of stars in a line would help more than my random set off of google.

Just had a thought about the j2000 ecliptic. Perhaps E:D is on a j3300 ecliptic?

Topic author
Redden Alt-Mer
Posts: 6
Joined: 17.12.2017
With us: 6 years 11 months

Post #11by Redden Alt-Mer » 24.12.2017, 09:22

Thanks, I'll give it a try. About the JD3300, as you can see in the code snippets above I tried to set the time correctly, but as far as I could see, this does not influence the output of the get_position function.

I'm tempted of using a brute-force approach to this and trying to rotate the position of (0, 360) degrees until coordinates match. Any help on rotating a position from a celestia script is welcome :)


Return to “Scripting”