calculate right ascention and declanation from telescope angles

  arduino, astronomy, c++

Im making a telescope controller program that has an IMU sensor chip attached to it (Arduino) using I2C bus. The IMU chip has built in 3-axis gyro, magnetometer, and accelerometer and sends readings about the horizontal and vertical angle of the telescope.

I need to calculate the right ascension and declination values of where the telescope is pointing by using only the raw local horizontal and vertical angles that i read from the IMU, plus the lat,long, and time.

Does anybody know the equations for that? pseudo code is below

double angx=IMU_I2C(COMPASS.X); // horiz angle of telescope
double angy=IMU_I2C(COMPASS.Y); // vert angle of telescope
double lat=GPS(LATITUDE);
double long=GPS(LONGITUDE);
double time=get_local_time();
double RA=get_ra(lat,lon,angx,angy,time); //<<-- need this
double DEC=get_dec(lat,lon,angx,angy,time); //<<-- need this

I been trying different things for the past week but cant get anything to work.

Any help would be great


Source: Windows Questions C++