Log in

View Full Version here: : Conversion of Coordinates to RA and Dec


angelof
14-12-2018, 03:51 PM
Greetings.

I have been given a 3D vector and I need to convert this to RA and Dec.

The following vector is for Acrux
j2000":"[-0.449409, -0.0523899, -0.891789]

I need a formula to convert the x, y, and z to the RA and Dec

http://stellarium.org/doc/0.18/remoteControlApi.html

Is someone able to provide me with a formula so I can create a couple of functions in Java to return the values for a program I am writing? I would prefer that the RA and Dec be returned in degrees.

Thanks

kens
14-12-2018, 05:45 PM
Declination is the arcsin of z
RA is the arctan of y/x.
Use atan2 or its equivalent to avoid div by zero error if x=0

EDIT: Looks like you need to add 180 degrees to get RA

Eratosthenes
14-12-2018, 07:43 PM
Could try one of these two sources?

http://www.castor2.ca/04_Propagation/14_Sat_Equat/index.html
https://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesi an_coordinates

angelof
16-12-2018, 01:31 PM
Thanks. I worked it out with a little help
To get dec in degrees and ra in hours I did this


double dec = Math.asin(z) / Math.PI * 180;

double ra = (((Math.atan2(x, y) * 180 / Math.PI -90) * -1 / 360 * 24) + 24) % 24;

Thanks

Eratosthenes
16-12-2018, 08:13 PM
Math.?

lazjen
19-12-2018, 04:42 PM
Java language - package