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