Converting From Cartesian Co-Ords To RA - Dec
Converting From Cartesian Co-Ords To RA - Dec
Converting From Cartesian Co-Ords To RA - Dec
2010-Apr-01, 05:51 AM #1
+x is directly toward the galactic core from Sol, +z is toward +90° in galactic longitude (I think that's
spinward?) from Sol, and +y is "above" Sol so that +z points to the left if you're looking down along
the y-axis while +x points toward the core.
I think I need to convert the XYZ to galactic coordinates, and then the galactic coordinates to
Equatorial RA/Dec coordinates. I can already go the other way (i.e. convert RA/Dec to XYZ) and it
seems somewhat complicated - I was just wondering if there was an easy way to do it that was
already explained somewhere, or whether I have to slog through lots of nasty trigonometry to figure
out what I want to do.
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 1/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
2010-Apr-01, 06:37 AM #2
And just to show I've done something - the way my converter works at the moment is to go from
RA/Dec to alpha/delta (these are decimal conversions of RA/Dec) to galactic longitude/latitude to XYZ.
Sirius is at RA 6h 45m 8.9s, Dec -16° 42' 58", at a distance of 8.578 ly (according to RECONS).
Converting that to <x,y,z> coordinates relative to Sol, that's at <-5.76, -1.33, -6.22>.
I want to go the other way from that so I first have to convert that to galactic coordinates:
Doing this gives me glat = -8.89°, glon = 227.23° which agrees with the known glat/glon for Sirius.
So all good so far.
But looking at the formula I have for converting alpha/delta to RA/Dec, I think I have a problem. The
equation I have is:
Code:
glat = ASIN(COS(delta)*COS(27.128251)*COS(alpha - 192.859481)+SIN(delta)*SIN(27.128251))
glon = 32.931918 + ATAN2((COS(delta)*SIN(alpha - 192.859481)*COS(27.128251)),(SIN(delta)-SIN(
ATAN2 is an Excel function where "ATAN2(a,b) equals ATAN(b/a), except that a can equal 0 in ATAN2."
I need to reverse this to figure out alpha and delta, but I'm not sure if I need to change the numbers
in here in the process. Apparently (according to my notes), the 32.931918 is the (longitude of the?)
Ascending Node of the Galactic Equator in J2000.0 co-ords, 192.859481 is the North Galactic Pole
(NGP) longitude in J2000.0 co-ords, and 27.128251 is the NGP latitude in J2000.0 co-ords. In other
words, they're where the NGP and Ascending Node of the Galactic Equator are located in the Equatorial
system. Do I need to change these to where the North Equatorial Pole and Ascending Node of the
Equatorial equator are located in the Galactic co-ordinate system? (I have no clue how to do that!). Or
do I just keep those numbers as they are when reversing the formula?
(more to the point, how do I reverse the glat equation? It's got both alpha and delta in it, don't I need
to be able to figure them out separately??)
[Note to Grant (if he's reading this) - you might remember this, I think you and I and a few others on
the Celestia boards hammered this out a few years ago. Now I'm trying to go the other way, so I can
convert a list of XYZ coordinates into RA/Dec so that I can visualise the stars for which I have the XYZ
coords in Celestia. ]
Last edited by EDG; 2010-Apr-01 at 07:35 AM.
2010-Apr-01, 07:47 AM #3
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 2/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
Rearranging the glat equation, I think I can get alpha as the subject, expressed in terms of delta and
glat:
Code:
(alpha - 192.859481) = ACOS{SIN(glat) - [SIN(delta)*SIN(27.128251)]/[COS(delta)*COS(27.128251
I think it's easier to keep it as (alpha - 192.859481) for now. So I guess I can substitute that for
(alpha - 192.859481) in the glon equation?
Code:
glon = 32.931918 + ATAN2((COS(delta)*SIN(ACOS{SIN(glat) - [SIN(delta)*SIN(27.128251)]/[COS(de
2010-Apr-01, 12:38 PM #4
Any chance you can use an Equatorial coordinate system for your x, y, z axes? It becomes a lot easier
then.
2010-Apr-01, 12:58 PM #5
I had a pair of spreadsheets that did this, but I lost one somehow.
One gave me the x,y,z coords, and the other gave the RA, Decl, and Dist. from any point in the galaxy.
The way I did it was simply set the new position to 0,0,0, and reverse. Of course, this made the new 0
Decl, 0 RA parallel to that on Earth.
From Sirius, Sol is <+5.76, +1.33, +6.22> ly. Reverse the trig and the answer shuld come out the
opposite of the as-seen-from-earth values.
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 3/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
2010-Apr-01, 03:12 PM #6
The problem is that I've only got the XYZ coords (in the galactic frame) for the stars. I'm actually
trying to convert them to RA/Dec so I can put them into Celestia, because (AFAIK) Celestia only allows
you to place stars using RA/Dec co-ordinates.
2010-Apr-01, 05:04 PM #7
Translate the galactic frame coordinates to geocentric by subtracting the XYZ coordinates of earth in
the galactic frame you are using. If your axes do not correspond with conventional equatorial axes,
rotate them to the conventional frame using appropriate matrix math or trignometric functions for axis
rotation. Afterward, the standard equations found in many places on the web will work.
2010-Apr-01, 05:28 PM #8
None of which helps me at all - it's the "appropriate matrix math or trigonometric functions for axis
rotation" that I'm stuck on. I'm hoping someone can walk me through the process here.
(also, it turns out that the ATAN2 function actually "Returns the arctangent, or inverse tangent, of the
specified x- and y-coordinates. The arctangent is the angle from the x-axis to a line containing the
origin (0, 0) and a point with coordinates (x_num, y_num). The angle is given in radians between -pi
and pi, excluding -pi.". How do I figure out the inverse of that?!)
EDIT: Though actually, if I could figure out a way to convert the Galactic XYZ directly to Equatorial XYZ
that could make things easier. Though since Earth (and Sol) are at <0,0,0> in both frames I'm not
sure how to do that since it'd involve rotating things.
2010-Apr-01, 06:20 PM #9
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 4/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
You need the equations and not just the answers, right? (Because you can jump straight to the answer
once you have the galactic coords)
EDIT: Also, I think Sirius' coordinates are (-5.76, -6.22, -1.33) and not (-5.76, -1.33, -6.22). At least
my maths doesn't work with the latter set.
Yep, I just need the equations. I can find plenty of webpages saying how to convert from Galactic to
Equatorial, but not the other way round (I guess it doesn't come up much ).
And you're right about the coords - my spreadsheet flips the y and z coords around (forgot to mention
that earlier, sorry). As long as the numbers I get are right I can correct for that .
Does your reference frame look like the one on this link?
http://en.wikipedia.org/wiki/Galactic_coordinate_system
Yes - I can figure out the galactic coordinates for the stars, along with their distances from Sol. What I
need is to find where the stars would be in the equatorial coordinate system (i.e. right ascension and
declination).
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 5/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
You'll need that pesky trig then. It's not that difficult, but I will have to spend a few hours with my
geometry book. Now Grant probably has this memorized- so PM him if you haven't already.
I have PMed EDG_ with what I hope is the answer. I had to resort to PM because our office internet
filter began blocking access to the thread for some reason. I am home now and so refer you to my PM.
Yeah, I pm'd Grant already, he helped me figure out the conversion going from Equatorial to Galactic
Veeger - Thanks for the PM, I'll try that out when I get home.
PraedSt - if you feel like giving it a shot as well, I'd really appreciate it
Yeah, I pm'd Grant already, he helped me figure out the conversion going from Equatorial to Galactic
Veeger - Thanks for the PM, I'll try that out when I get home.
PraedSt - if you feel like giving it a shot as well, I'd really appreciate it
Oh I'll definitely do it, it's an interesting problem. Thing is, I'll only have that amount of time on
Sunday, so I hope you don't get too stressed waiting.
Hopefully Veeger won't mind me posting what he sent me in his PM here, in case anyone else want to
look at it:
Remember to convert the degrees to radians before actualing calling the trig functions.
I think I'll be able to figure out b and l and then I can try these formulae.
I can only add that Veeger's conversion takes you to B1950.0 equatorial coordinates. You need
J2000.0 for Celestia. An extra fifty years precession has carried the galactic north pole and node away
from the nice round numbers of B1950.0.
To get to J2000.0, make the following substitutions in Veeger's formulae:
All the J2000.0 angles are rounded at six decimals; the B1950.0 angles were exact, by definition.
If anyone's interested, the first two angles are the right ascension and declination of the galactic north
pole, respectively. The third is the galactic longitude of the ascending node of the galactic plane on the
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 7/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
celestial equator.
Grant Hutchison
Remember to convert the degrees to radians before actualing calling the trig functions.
Great work Veeger. I took a shortcut and googled the formulas (about half way down the page).
Grant. The third angle is the equatorial longitude? (i.e. just longitude?) Otherwise I'm at a loss.
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 8/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
I think I'll be able to figure out b and l and then I can try these formulae.
By the way, in the atan function, when using the coordinate correct version (ATAN2 vs. ATAN) the
syntax I give is not right. The numerator will be the y parameter and the denominator will be the x
parameter. so the function should be atan2(x,y); where x = sin(b * DEG2RAD) * cos(27.128251 *
DEG2RAD) - cos(b * DEG2RAD) * sin(27.128251 * DEG2RAD) * sin((L - 32.931918) * DEG2RAD) and
y = cos(b * DEG2RAD) * cos((L - 32.931918)
The 33º is the galactic longitude of the ascending node of the galactic equator on the celestial equator
of B1950.0. That is, it's the angular distance along the galactic equator from the zero point of galactic
longitude to the node.
Grant Hutchison
Excellent, thanks all. I'm at home now, so I'll see if I can get this working
Though I'm still not entirely sure what the ATAN2 function does - AFAIK it's an Excel function, not an
actual mathematical function like arctan. How would I be able to enter ATAN2 into a program or a
calculator?
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 9/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
Hm, well... I tried calculating delta for Sirius using Veeger's formula (corrected for J2000) and ended
up with delta=0.920487 radians, but if I calculate Sirius' delta from its RA/Dec I get delta=-0.29175
radians. So something's going wrong somewhere I think...
(Sirius' galactic latitude (b) and galactic longitude (l) are -0.155165767 radians and -2.317269316
radians respectively, right? That's 227.2302 degrees glon and -8.89034 degrees glat?).
I'll see if I can work it up in excel. Entering 0,0 should give me the coordinates of the galactic center if
the formulae are correct.
Atan only returns values between +90 and -90 degrees. Atan2 produces results from +180 to -180 (or
0-360 depending on implementation).
If x and y are positive the result will be 0 to 90. If -x and +y then the result is 90 to 180. If -x and -y
then -90 to -180 and if +x and -y then 0 to -90.
The formulae I gave you worked for me, EDG_. Using your galactic coordinates for Sirius, I got
-16.71611109 and 101.2870833 for equatorial coordinates in degrees.
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 10/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
ok check your PM
Ah... I found the problem in my delta formula - I had 2.317269316 as my galactic longitude for Sirius,
when it's actually -2.317269316 (note the negative sign). That concerns me, as the negative sign isn't
there because of how I converted from the XYZ to galactic coordinates.
The result of the missing -ve sign is that when I do the sin (l - 32.931918) part, I get a result of
0.98529529 instead of -0.246970773. So how do I fix this so that the sign of the galactic longitude
that I calculate comes out correctly?
Page 1 of 2 1 2 Last
Similar Threads
Replies: 48
Last Post: 2011-Oct-26, 03:14 AM
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 11/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
Replies: 5
Last Post: 2011-Sep-25, 09:45 PM
Replies: 5
Last Post: 2010-Mar-19, 08:07 AM
Replies: 16
Last Post: 2007-Jan-18, 10:53 AM
You may BB
not post code is
new On
threads Smilies
You may are On
not post [IMG]
replies code is
You may On
not post
attachments
Y
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 12/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?
You may
not edit
your posts
[VIDEO] code is On
HTML code is Off
Forum
Rules
https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 13/13