1
$\begingroup$

First off, let me say that I'm not a Mathematical wizard. Be easy on me :)

I am looking to draw a subsection of space using OpenGL on the iPhone. I have a star's RA and Dec and am needing to somehow calculate a set of cartesian coordinates based on those values.

My research has led me to believe that I'm needing to run the RA/Dec through a projection algorithm to accurately plot these "points" on a grid. Is this true? If so, I have been suggested to use the "Azimuthal equidistant projection."

Unfortunately, I don't understand all the greek lettering and where my RA/Dec fits in those equations. Am I way off in left field here?

Update

Here is a function I crafted using the information over at: http://www.projectrho.com/smap03.html

/**
* Converts Right-Ascension, Declination, and Distance to Cartesian Coordinates
*
* DEC should be passed in as decimal degrees (0-360)
* RA should be passed in as decimal hours (0-24)
* Distance should be passed in as parsecs. To convert parsecs to light-years, multiply by 3.262
*
* @author Jesse Bunch
*/
+(CartesianCoords *) ConvertSpehericalToCartesianWithRA: (double)dblRA DEC: (double)dblDEC DIST: (double)dblDIST {

    CartesianCoords *objCartesian = [[[CartesianCoords alloc] init] autorelease];

    double dblPHI, dblTHETA, dblRHO, dblRVECT;

    dblPHI = [AstroUtils ConvertDegreesToRadians: (dblRA * 15)];
    dblTHETA = [AstroUtils ConvertDegreesToRadians: dblDEC];
    dblRHO = dblDIST;
    dblRVECT = dblRHO * cos(dblTHETA);

    objCartesian.X = dblRVECT * cos(dblPHI);
    objCartesian.Y = dblRVECT * sin(dblPHI);
    objCartesian.Z = dblRHO * sin(dblTHETA);

    return objCartesian;


}

http://www.projectrho.com/smap03.html

1 Answers 1

3

RA is like longitude. But it is usually written in terms of hours, minutes and seconds. 24 hours is equivalent to 2 $\pi$ radians. RA=12:24:30 is 12 hours, 24 minutes, 30 seconds. To convert to radians 2$\pi$ * ((12hours/24) + 24minutes/24/60 + 30seconds/24/60/60).

DEC is like latitude. It is usually written in terms of degrees minutes and seconds. It goes from +90 (north pole) to -90 degrees (south pole). 180 degrees is equivalent to $\pi$ radians. DEC= -15:30:10 is -15 degrees, 30 minutes, 10 seconds.

After you convert the two angles to radians then you just have two angles like $\phi, \theta$ in spherical coordinates. You can project into 2D however you want but if you need a star field that is small then typically you don't bother with any projection and just plot as if RA and DEC were cartesian (multiplying the RA by cosine of the dec though to take into account that a second in RA is bigger on the equator than at the north pole).

It's not as bad as it sounds. The only really bizarre thing is that East and West are flipped compared to an earth type map. If you get used to reading sky maps you will have to be careful about this afterwards! (Looking up is different than looking down).

It might also be useful for you to know that RA=12 hours is up in the night sky in March and RA=18h up in June, RA=0h up in Sept and RA=6h up in Dec (set with the equinox). And if you are in the northern hemisphere you can't see things in the sky that have very negative DECs.

  • 0
    Thanks for your explanation. After posting, I stumbled across the link in my updated question. From that, I crafted the function above to convert my RA/Dec and Distance into 3D cartesian coordinates. I know you may not be a programmer, but can you check out my math to make sure it makes sense?2011-07-21
  • 1
    @Jesse I am confused by your code. You specify in degrees and then it looks like you want to convert to radians before taking cosine and sine. IF DEC is in degrees then multiply by $\pi/180$. Same for RA (if in degrees then I would have assumed going from 0 to 360 not 0 to 24hours). The 15 you have there is 360/24 so your comments are not consistent with your arithmetic factor. To check, the north pole should have $z=\rho$, so $z=\rho*\sin(\theta)$ is fine at $\theta=\pi/2$. This part looks good.2011-07-22
  • 0
    You're right. In my comments, I specified that both RA/Dec should be passed in decimal degrees. In fact, I am passing in DEC as decimal degrees and RA as decimal hours (0-24). Thus, I was converting the decimal hours to decimal degrees by multiplying by 15. My "ConvertDegreesToRadians" method does multiply by π/180. Am I still wrong? If so, would you mind correcting the arithmetic in my code?2011-07-22
  • 1
    okay I see it now in AstroUtils. Looks fine then!2011-07-22
  • 0
    Thanks, @Alice. Your time is much appreciated.2011-07-22