Converting cartesian to RA/Dec

george7378

DON'T PANIC
Addon Developer
Donator
Joined
Jun 26, 2009
Messages
1,045
Reaction score
0
Points
36
Hi everyone,

I have the position of a satellite in topocentric cartesian coordinates (i.e. the position of the satellite is given in [x,y,z] coordinates with the Earth-bound observer at the origin) and I want to convert this to and RA and Dec position as seen by the observer. I have seen formulae on this site:

http://www.castor2.ca/04_Propagation/14_Sat_Equat/index.html

...and the one for declination works fine, but the RA formula sometimes gives me a number larger than 360 (I'm working in degrees rather than hours) and even when I subtract 360 it isn't correct. This seems to happen about half the time, and I can't find any alternative formulae! Can anyone help?

Thanks!
 

Phoenix

New member
Joined
Nov 17, 2009
Messages
72
Reaction score
0
Points
0
I wrote this constructor as part of a polar coordinates class.

Code:
/// Constructor.
/// @param[in] rVector A unit vector containing a direction for conversion to latitude and longitude.  Note that
/// longitude is from 0 to 360 degrees East. That is, a Vector3(-1, 0, 0) is 270 degrees East. A Vector3(0, 1, 0)
/// is 90 degrees North, or +90, and conversely, Vector3(0, -1, 0) is 90 degrees South, or -90. Remember that
/// longitude and latitude are stored as radians. Use ToDegrees to convert.
template <typename T> inline Polar<T>::Polar(const Vector3<T> &rV) :
  Latitude(static_cast<T>(asin(rV.y))),
  Longitude(static_cast<T>(Pi-atan2(rV.x, rV.z)))
{}
 
Last edited:

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,678
Reaction score
902
Points
128
Location
Code 347
Hi everyone,

I have the position of a satellite in topocentric cartesian coordinates (i.e. the position of the satellite is given in [x,y,z] coordinates with the Earth-bound observer at the origin) and I want to convert this to and RA and Dec position as seen by the observer. I have seen formulae on this site:

http://www.castor2.ca/04_Propagation/14_Sat_Equat/index.html

...and the one for declination works fine, but the RA formula sometimes gives me a number larger than 360
Thanks!

I'm not sure what Topocentric RA/Dec is! But I think the last formula for a on that web page is wrong, it should be "a = 360 plus arctan(y/x)"
like this:

a = 360 + tan-1 [ ys / xs ]
FOR ys<0 AND xs>0

Because when y/x is negative, arctan(y/x) is also negative.
So you should add it to 360.

Any good?
 

george7378

DON'T PANIC
Addon Developer
Donator
Joined
Jun 26, 2009
Messages
1,045
Reaction score
0
Points
36
Interstellar Planet: I don't think spherical polars work in this case because it's from the observer's point of view and the coordinate system is based at the centre of the Earth.

BrianJ: That makes sense, I'll give it a go! Topocentric means that the coordinates are shown with the observer at the origin, so topocentric Cartesian coordinates, in this case, tell you the distance from the observer to the satellite in x, y and z.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Just use atan2 instead of atan. This covers the whole circle (-pi, pi), so you don't need the awkward case distinctions.

Work in radians, not degrees, to avoid unnecessary trouble.

That link doesn't look too useful on polar coordinates in general. Look up any reference on spherical polar coordinates which should tell you how to convert from and to cartesian coordinates. Just remember that mathematicians tend to use the polar angle (measured from the north pole), while declination is measured from the equator.
 
Top