# plotting stars in cartessian coordinates using the stars ra and dec produces the wrong location of the stars

I am currently running into some problems with plotting some stars locations in a Cartesian coordinate system. The stars aren't in the right order and I'm not sure where I am going wrong.

I first use the equation (where S is a vector)

S = [cos(ra)*cos(dec), sin(ra)*cos(dec), sin(dec)]


to obtain a vector S of the star. I now want to obtain the x and y positions of the stars In terms of a 2d coordinate system so I use

c * sx = S * px / S* pz
c * sy = S * py / S* pz


where C is the scale ratio of pixels to tangent of the angle of the camera and P is the vector center of the camera.(Im using this because I'm trying to find the distance between each pair of stars when a photo of the stars is taken by a camera)

px = unit vector X
py = unit vector Y
pz = unit vector Z


and I solve for sx and sy. When I plot the stars location with sx and sy however I do not get the right locations of the stars. Any guidance?

• S is a scalar in this example. Is the code correct? – James K Aug 13 '16 at 8:18
• could you please clarify what is a vector, scalar, dot product etc. in your writing? This is extremely confusing and inconsistent – AtmosphericPrisonEscape Aug 13 '16 at 9:53
• in this example S is a vector! My apologies I wasn't sure how to add the notations for vectors and dot products – Continuum Aug 14 '16 at 17:48
• This MathJax tutorial may help.If $\hat{\mathrm p}_z= \vec P$, then your $\hat{\mathrm p}_x$ and $\hat{\mathrm p}_y$ look like my $\hat{\mathrm u}$ and $\hat{\mathrm v}$. – Mike G Aug 14 '16 at 18:36

A photograph of stars is essentially a gnomonic projection of part of the celestial sphere. If $\vec P$ is computed for the photograph center (RA, Dec) in the same way as $\vec S$, and the north celestial pole is $\hat{\mathrm k} = (0, 0, 1)^{\mathrm T}$, then the photograph has basis vectors perpendicular to $\vec P$ and each other, $$\hat{\mathrm u} = \frac{\vec P \times \hat{\mathrm k}}{\| \vec P \times \hat{\mathrm k} \|}, \hat{\mathrm v} = \frac{\hat{\mathrm u} \times \vec P}{\| \hat{\mathrm u} \times \vec P \|}$$ and you can project $\vec S$ onto the photograph as $$\left( \frac{\vec S \cdot \hat{\mathrm u}}{\vec S \cdot \vec P}, \frac{\vec S \cdot \hat{\mathrm v}}{\vec S \cdot \vec P} \right)$$ scaling as needed.
• $\vec P$ depends on the region of interest, e.g. for the Big Dipper you might center the photo at RA 12 h, Dec +55 deg and use $\vec P$ = (-0.57, 0.0, 0.82). To make $\hat{\mathrm u}$ and $\hat{\mathrm v}$ point west and north in the photo, I used a cross product with standard basis vector $\hat{\mathrm k}$ (aligned with +Z axis, north celestial pole). – Mike G Aug 13 '16 at 3:44