You are on page 1of 13

2/7/2021 Converting from Cartesian co-ords to RA/Dec?

User Name Password Log in Help Register


Remember Me?

What's New? Forum

FAQ Calendar Community Forum Actions Quick Links Advanced Search

Forum Science and Space Astronomy


Converting from Cartesian co-ords to
RA/Dec?
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages, select the forum that
you want to visit from the selection below.

Results 1 to 30 of 53 Page 1 of 2 1 2 Last

Thread: Converting from Cartesian co-ords to RA/Dec?

Thread Tools Search Thread Display

2010-Apr-01, 05:51 AM #1

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

Converting from Cartesian co-ords to RA/Dec?


So here's an odd question: I need to figure out a way to convert from XYZ coordinates in lightyears
relative to an origin (e.g. x,y,z = <+6, +2, -3>) into RA/Dec coordinates. Essentially, imagine that I'm
getting rid of all the stars around Sol, and replacing them with new ones - I know where they are in
terms of distances (in lightyears) along the XYZ axes, but I need to find where they'd be located in
Earth's sky (hence the need for RA/Dec).

+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.

Reply With Quote

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

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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:

Galactic latitude = ASIN (y / distance)


Galactic longitude = ACOS (x / (distance * cos ( [ASIN (y/distance)] )) )

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.

Reply With Quote

2010-Apr-01, 07:47 AM #3

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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

Now... does that help me at all?!

Reply With Quote

2010-Apr-01, 12:38 PM #4

Join Date: Sep 2008


Posts: 5,892
PraedSt
Order of Kilopi

Originally Posted by EDG_


+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.

Any chance you can use an Equatorial coordinate system for your x, y, z axes? It becomes a lot easier
then.

Reply With Quote

2010-Apr-01, 12:58 PM #5

Join Date: Oct 2005


Location: Northern Utah
Tog Posts: 6,213
Order of Kilopi

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?

I'm Not Evil.


An evil person would do the things that pop into my head.

Reply With Quote

2010-Apr-01, 03:12 PM #6

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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.

Reply With Quote

2010-Apr-01, 05:04 PM #7

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

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.

Reply With Quote

2010-Apr-01, 05:28 PM #8

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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.

Reply With Quote

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?

Join Date: Sep 2008


Posts: 5,892
PraedSt
Order of Kilopi

Originally Posted by EDG_


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.

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.

Reply With Quote

2010-Apr-01, 07:00 PM #10

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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 .

Reply With Quote

2010-Apr-01, 07:20 PM #11

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

Does your reference frame look like the one on this link?
http://en.wikipedia.org/wiki/Galactic_coordinate_system

Reply With Quote

2010-Apr-01, 07:24 PM #12

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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?

Reply With Quote

2010-Apr-01, 07:29 PM #13

Join Date: Sep 2008


Posts: 5,892
PraedSt
Order of Kilopi

Originally Posted by EDG_


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 )

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.

Reply With Quote

2010-Apr-01, 08:36 PM #14

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

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.

Reply With Quote

2010-Apr-01, 08:58 PM #15

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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

Reply With Quote

2010-Apr-01, 09:13 PM #16

Join Date: Sep 2008


Posts: 5,892
PraedSt
Order of Kilopi

Originally Posted by EDG_


https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 6/13
2/7/2021 Converting from Cartesian co-ords to RA/Dec?

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.

Reply With Quote

2010-Apr-01, 09:16 PM #17

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

Hopefully Veeger won't mind me posting what he sent me in his PM here, in case anyone else want to
look at it:

Originally Posted by Veeger


If you make your coordinate system look like the one on the wiki page, convert your XYZ to l/b using
conventional cartesian to equatorial formula, then convert to earth equatorial using the following:

delta = asin(cos b cos(27.4) sin(l-33) + sin b sin(27.4))


alpha = atan2[( cos b cos(l-33)) / (sin b cos(27.4) - cos b sin(27.4) sin(l-33))] + 192.25

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.

Reply With Quote

2010-Apr-01, 10:36 PM #18

Join Date: Jul 2005


Posts: 20,072
grant hutchison
Order of Kilopi

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:

192.25º => 192.859481º


27.4º => 27.128251º
33º => 32.931918º

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

Reply With Quote

2010-Apr-01, 10:51 PM #19

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

Hey, what's fifty or sixty years in galactic time?

Reply With Quote

2010-Apr-01, 11:03 PM #20

Join Date: Sep 2008


Posts: 5,892
PraedSt
Order of Kilopi

Originally Posted by Veeger


If you make your coordinate system look like the one on the wiki page, convert your XYZ to l/b using
conventional cartesian to equatorial formula, then convert to earth equatorial using the following:

delta = asin(cos b cos(27.4) sin(l-33) + sin b sin(27.4))


alpha = atan2[( cos b cos(l-33)) / (sin b cos(27.4) - cos b sin(27.4) sin(l-33))] + 192.25

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.

Reply With Quote

2010-Apr-01, 11:03 PM #21

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

Originally Posted by EDG_


Hopefully Veeger won't mind me posting what he sent me in his PM here, in case anyone else want to
look at it:

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)

Reply With Quote

2010-Apr-01, 11:23 PM #22

Join Date: Jul 2005


Posts: 20,072
grant hutchison
Order of Kilopi

Originally Posted by PraedSt


Grant. The third angle is the equatorial longitude? (i.e. just longitude?) Otherwise I'm at a loss.

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

Reply With Quote

2010-Apr-02, 12:01 AM #23

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

Excellent, thanks all. I'm at home now, so I'll see if I can get this working

Reply With Quote

2010-Apr-02, 12:03 AM #24

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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?

Reply With Quote

2010-Apr-02, 12:26 AM #25

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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?).

This is the formula I entered into excel:


Code:
delta =ASIN((COS(glat)*COS(NGP lat)*SIN(glon-ASC)+(SIN(glat)*SIN(NGP lat))))

where all the angles are in radians.

Reply With Quote

2010-Apr-02, 12:54 AM #26

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

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.

Reply With Quote

2010-Apr-02, 01:15 AM #27

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

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.

Reply With Quote

2010-Apr-02, 01:24 AM #28

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?

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

OK, my excel implementation must be screwy... I'll check it again

Reply With Quote

2010-Apr-02, 01:29 AM #29

Join Date: Dec 2007


Posts: 1,263
Veeger
Established Member

ok check your PM

Reply With Quote

2010-Apr-02, 04:24 AM #30

Join Date: Apr 2007


Posts: 2,364
EDG
Established Member

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?

Reply With Quote

Page 1 of 2 1 2 Last

Quick Navigation Astronomy Top

« Previous Thread | Next Thread »

Similar Threads

Converting software to hardware


By KhashayarShatti in forum Off-Topic Babbling

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?

Converting Jupiter to a star Replies: 15


By KhashayarShatti in forum Science and Technology Last Post: 2011-Sep-27, 05:04 PM

Earth/Space flatness/curvature in cartesian


coordinates
By iantresman in forum Space/Astronomy Questions and Answers

Replies: 5
Last Post: 2011-Sep-25, 09:45 PM

Orbits: Cartesian to orbital elements?


By Alpharomeo81 in forum Space/Astronomy Questions and Answers

Replies: 5
Last Post: 2010-Mar-19, 08:07 AM

Converting Powerpoint to movie files


By Sticks in forum Off-Topic Babbling

Replies: 16
Last Post: 2007-Jan-18, 10:53 AM

Tags for this Thread

co-ordinate conversion, trigonometry


View Tag Cloud
Posting Permissions

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

-- CosmoQuest Contact Us Cosmoquest Archive Top

All times are GMT. The time now is 02:02 PM.

Powered by vBulletin® Version 4.2.3


Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.

Where would you like to explore today?

https://forum.cosmoquest.org/showthread.php?102634-Converting-from-Cartesian-co-ords-to-RA-Dec&s=2b8bd1a7091d8e6a60f0e345f217c920 13/13

You might also like