<p>Ok, it needed some searching with the right words (astrometry, standard coordinates) to actually find the equations I needed. I'll try to go through the process here to make this a complete answer to my own question.</p>
<p>The key equation here is the conversion of Celestial Coordinates (RA, Dec) to Standard Coordinates (X, Y) on a tangent plane of the sky. This figure from the article <a href="https://www.researchgate.net/publication/333841450_Astrometry_The_Foundation_for_Observational_Astronomy" rel="nofollow noreferrer">Astrometry: The Foundation for Observational Astronomy</a> (Amith Govind et al) explains what is needed.</p>
<p><a href="https://i.sstatic.net/moS6O.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/moS6O.png" alt="Standard coordinates" /></a></p>
<p>From the same article we can find the equations for calculating the Standard Coordinates:</p>
<p><span class="math-container">$$X = \frac{cos(\delta)sin(\alpha - \alpha_0)}{cos(\delta_0)cos(\delta)cos(\alpha - \alpha_0) + sin(\delta)sin(\delta_0)}$$</span>
<span class="math-container">$$Y = \frac{sin(\delta_0)cos(\delta)cos(\alpha - \alpha_0) - cos(\delta_0)sin(\delta)}{cos(\delta_0)cos(\delta)cos(\alpha - \alpha_0) + sin(\delta)sin(\delta_0)}$$</span></p>
<p>where <span class="math-container">$\alpha$</span> is the angle RA of the star and <span class="math-container">$\delta$</span> is the angle Dec of the star, and <span class="math-container">$\alpha_0$</span> is the field center RA and <span class="math-container">$\delta_0$</span> the field center Dec, all in radians.</p>
<p>With these equations we get the Standard Coordinates in radians in respect to the center of the field. To get the pixel coordinates, those coordinates will still need to be multiplied by the amount of pixels per radians and those rations can be calculated from the focal length, binning, image resolution and the camera sensor pixel size. If we want to account for a possible field rotation, we will need to factor in the rotation of the coordinates by forming the coordinates from X and Y components with sine and cosine factors. In addition, as the above illustration shows the X coordinate will be mirrored, so we'll need to flip the final resulting X coordinate.</p>
<p>So proceeding on with pseudocode, we have:</p>
<pre><code>imageWidthRad = 2 * atan((pxSize * bin * widthPx / 1000.0) / (2 * fLen))
imageHeightRad = 2 * atan((pxSize * bin * heightPx / 1000.0) / (2 * fLen))

pixelsPerRadW = widthPx / imageWidthRad
pixelsPerRadH = heightPx / imageHeightRad

imageCenterX = widthPx / 2
imageCenterY = heightPx / 2
</code></pre>
<p>(<em>note that pixel size (in microns) and binning is assumed to be the same for both width and height here</em>)</p>
<p>With star RA, Dec (s_ra, s_dec) and field center RA, Dec (c_ra, c_dec) in radians we get the standard coordinates:</p>
<pre><code>stdX = cos(s_dec) * sin(s_ra - c_ra) / (cos(c_dec) * cos(s_dec) * cos(s_ra - c_ra) + sin(c_dec) * sin(s_dec))
stdY = (sin(c_dec) * cos(s_dec) * cos(s_ra - c_ra) - cos(c_dec) * sin(s_dec)) / (cos(c_dec) * cos(s_dec) * cos(s_ra - c_ra) + sin(c_dec) * sin(s_dec))
</code></pre>
<p>If rotation is assumed as zero, we now have everything we need to calculate the star positions:</p>
<pre><code>starPixelX = pixelsPerRadW * stdX + imageCenterX
starPixelY = pixelsPerRadH * stdY + imageCenterY
starPixelX = width - starPixelX
</code></pre>
<p>To account for field rotation, we need to change it a little. Let's add the field rotation angle <span class="math-container">$r$</span>.</p>
<pre><code>starPixelX =  cos(r) * pixelsPerRadW * stdX + sin(r) * pixelsPerRadH * stdY + imageCenterX
starPixelY = -sin(r) * pixelsPerRadW * stdX + cos(r) * pixelsPerRadH * stdY + imageCenterY
starPixelX = width - starPixelX
</code></pre>
<p>With this, the star positions get rotated accordingly. At 90 degrees (cos(90deg) == 0, sin(90deg) == 1) we see that X effectively becomes Y and vice versa.</p>
<h2>Conclusion</h2>
<p>With a program that reads the RA, Dec coordinates of Tycho-2 catalog stars I drew the stars to an image using these equations, using the following parameters:</p>
<ul>
<li>Pixel size (pxSize) = 3.8 microns</li>
<li>Image Width (widthPx) = 4656</li>
<li>Image Height (heightPx) = 3520</li>
<li>Center RA (c_ra) = 194.464 deg</li>
<li>Center Dec (c_dec) = 71.217 deg</li>
<li>Binning (bin) = 1</li>
<li>Focal length (fLen) = 25mm</li>
<li>Rotation (r) = -268 deg</li>
</ul>
<p>Resulting in this image:
<a href="https://i.sstatic.net/xIQn8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xIQn8.png" alt="Generated image" /></a></p>
<p>I then ran this through <a href="http://nova.astrometry.net" rel="nofollow noreferrer">http://nova.astrometry.net</a> astrometric solver, and successfully solved the image with the calculated (RA, Dec) center being: (194.461, 71.223).</p>
<p>As astrometry.net annotated with grid:
<a href="https://i.sstatic.net/E7YgH.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E7YgH.jpg" alt="Generated solved image with annotations" /></a></p>
<p>So there it is, projected stars from sphere to a flat plane.</p>

CC BY-SA 4.0
2022-06-14T07:46:25.710Z
Thanks for sharing, this is really usefull read. Can you share the rest of it, how did you took the stars from the catalog, draw an image with them?
Falco Peregrinus
CC BY-SA 4.0
2021-04-20T17:19:43.293Z
2021-04-20T17:19:43.293Z
AstroDuck
<p>This isn’t code for a full implementation, but you could do something like this:</p>
<ol>
<li><p>Transform your RA, Dec coordinates (which are spherical polar coordinates, just all with the same <span class="math-container">$r$</span>) to Cartesian <span class="math-container">$x, y, z$</span> coordinates.   (The <span class="math-container">$r$</span> value you would use here is arbitrary, for example <span class="math-container">$r = 1$</span>, and should be the same for all stars, not their real distances; you're just projecting them onto a sphere so you can do the transformation.)</p>
</li>
<li><p>Apply a <a href="https://www.geeksforgeeks.org/computer-graphics-3d-rotation-transformations/" rel="nofollow noreferrer">coordinate frame rotation </a>using your field-center RA, Dec coordinates (or perhaps their complements) as the rotation angles, so that the field center direction is the new <span class="math-container">$z$</span> axis.</p>
</li>
<li><p>Plot the resulting new <span class="math-container">$x, y$</span> coordinates, ignoring <span class="math-container">$z$</span>.</p>
</li>
</ol>
<p>You might have to do a further rotation of those <span class="math-container">$x, y$</span> coordinates to get the plot oriented the way you want, or maybe there’s a clever way to do that with the proper choice of angles in step 2.</p>

CC BY-SA 4.0
2021-04-18T14:11:09.623Z
2021-04-18T16:03:52.243Z
2021-04-18T16:03:52.243Z
Eric Jensen
<p>I would like to simulate a telescope camera view, projecting (RA, Dec) coordinate sets to a 2D plane. So effectively the need is to convert Equatorial coordinates to (x, y) coordinates, when we can know how many degrees a single pixel spans.
For convenience I'm using degrees for RA and Dec here, and the code is just pseudocode.</p>
<p>The following base information is provided as an example:
Imaging equipment:</p>
<ul>
<li>Telescope focal length in mm (<em>flen</em>): 420</li>
<li>Image resolution (<em>widthPx</em>, <em>heightPx</em>): 4000 * 3000</li>
<li>Pixel size in microns (<em>pxSize</em>): 8</li>
<li>Binning (<em>bin</em>): 1</li>
</ul>
<p>So from my understanding we can calculate a few things from this for starters.
The field of view in degrees should be:</p>
<pre><code>fovW = radToDeg( 2 * atan((pxSize * bin * widthPx / 1000) / (2 * flen)) )
fovH = radToDeg( 2 * atan((pxSize * bin * heightPx / 1000) / (2 * flen)) )
</code></pre>
<p>And from this we could derive:</p>
<pre><code>pixelsPerDegWidth = widthPx / fovW;
pixelsPerDegHeight = heightPx / fovH;
</code></pre>
<p>For locations closer to the equator I can get some valid looking results using this formula:</p>
<pre><code>deltaRa = starRa - imageCenterRa
deltaRa = deltaRa &gt; 180 ? 360 + deltaRa : deltaRa
deltaDec = -1 * (starDec - imageCenterDec)

posX = deltaRa * cosdeg(starDec) * pixelsPerDegWidth + 0.5 * widthPx
posY = deltaDec * pixelsPerDegHeight + 0.5 * heightPx
</code></pre>
<p>With some catalog star positions projected using this formula, I can even get Astrometry.net solver to correctly identify the center position.
However when we move to the poles this comes crashing down.</p>
<p>So let's go ahead and use a target center point near the pole:</p>
<ul>
<li>RA 30 degrees (<em>imageCenterRa</em>)</li>
<li>Dec 89 degrees (<em>imageCenterDec</em>)</li>
</ul>
<p>Let's also say that we have a hypothetical star at RA, Dec (220, 89.2) - this is close to the pole, and both the star and the pole gets included in the image.
What kind of formula should we use to get the correct location and to draw the area correctly even in the polar regions?</p>
<p>I've been looking for an example for a while but haven't come up with any. I've seen some formulas that may be just the thing I'm looking for but my thick skull loves examples - hence why I included some exact numbers here, as I would love to see how this would be calculated in practice.</p>
<p>So to summarize: how would we calculate the (X, Y) coordinate in the image for the star at RA, Dec (220, 89.2)?</p>

<telescope><coordinate><astrometry><projection>
Plotting Equatorial coordinates to X,Y plane (simulating telescope/camera view)
AstroDuck
# Plotting Equatorial coordinates to X,Y plane (simulating telescope/camera view)

(Asked by: username_0 on 2021-04-18)

I would like to simulate a telescope camera view, projecting (RA, Dec) coordinate sets to a 2D plane. So effectively the need is to convert Equatorial coordinates to (x, y) coordinates, when we can know how many degrees a single pixel spans.
For convenience I'm using degrees for RA and Dec here, and the code is just pseudocode.
The following base information is provided as an example:
Imaging equipment:

Telescope focal length in mm (flen): 420
Image resolution (widthPx, heightPx): 4000 * 3000
Pixel size in microns (pxSize): 8
Binning (bin): 1

So from my understanding we can calculate a few things from this for starters.
The field of view in degrees should be:
fovW = radToDeg( 2 * atan((pxSize * bin * widthPx / 1000) / (2 * flen)) )
fovH = radToDeg( 2 * atan((pxSize * bin * heightPx / 1000) / (2 * flen)) )

And from this we could derive:
pixelsPerDegWidth = widthPx / fovW;
pixelsPerDegHeight = heightPx / fovH;

For locations closer to the equator I can get some valid looking results using this formula:
deltaRa = starRa - imageCenterRa
deltaRa = deltaRa > 180 ? 360 + deltaRa : deltaRa
deltaDec = -1 * (starDec - imageCenterDec)

posX = deltaRa * cosdeg(starDec) * pixelsPerDegWidth + 0.5 * widthPx
posY = deltaDec * pixelsPerDegHeight + 0.5 * heightPx

With some catalog star positions projected using this formula, I can even get Astrometry.net solver to correctly identify the center position.
However when we move to the poles this comes crashing down.
So let's go ahead and use a target center point near the pole:

RA 30 degrees (imageCenterRa)
Dec 89 degrees (imageCenterDec)

Let's also say that we have a hypothetical star at RA, Dec (220, 89.2) - this is close to the pole, and both the star and the pole gets included in the image.
What kind of formula should we use to get the correct location and to draw the area correctly even in the polar regions?
I've been looking for an example for a while but haven't come up with any. I've seen some formulas that may be just the thing I'm looking for but my thick skull loves examples - hence why I included some exact numbers here, as I would love to see how this would be calculated in practice.
So to summarize: how would we calculate the (X, Y) coordinate in the image for the star at RA, Dec (220, 89.2)?

**Tags:** telescope, coordinate, astrometry, projection


---

## 2 answers

### Answer by username_0 on 2021-04-20. Score: 2 | Accepted answer

Ok, it needed some searching with the right words (astrometry, standard coordinates) to actually find the equations I needed. I'll try to go through the process here to make this a complete answer to my own question.
The key equation here is the conversion of Celestial Coordinates (RA, Dec) to Standard Coordinates (X, Y) on a tangent plane of the sky. This figure from the article Astrometry: The Foundation for Observational Astronomy (Amith Govind et al) explains what is needed.

From the same article we can find the equations for calculating the Standard Coordinates:
$$X = \frac{cos(\delta)sin(\alpha - \alpha_0)}{cos(\delta_0)cos(\delta)cos(\alpha - \alpha_0) + sin(\delta)sin(\delta_0)}$$
$$Y = \frac{sin(\delta_0)cos(\delta)cos(\alpha - \alpha_0) - cos(\delta_0)sin(\delta)}{cos(\delta_0)cos(\delta)cos(\alpha - \alpha_0) + sin(\delta)sin(\delta_0)}$$
where $\alpha$ is the angle RA of the star and $\delta$ is the angle Dec of the star, and $\alpha_0$ is the field center RA and $\delta_0$ the field center Dec, all in radians.
With these equations we get the Standard Coordinates in radians in respect to the center of the field. To get the pixel coordinates, those coordinates will still need to be multiplied by the amount of pixels per radians and those rations can be calculated from the focal length, binning, image resolution and the camera sensor pixel size. If we want to account for a possible field rotation, we will need to factor in the rotation of the coordinates by forming the coordinates from X and Y components with sine and cosine factors. In addition, as the above illustration shows the X coordinate will be mirrored, so we'll need to flip the final resulting X coordinate.
So proceeding on with pseudocode, we have:
imageWidthRad = 2 * atan((pxSize * bin * widthPx / 1000.0) / (2 * fLen))
imageHeightRad = 2 * atan((pxSize * bin * heightPx / 1000.0) / (2 * fLen))

pixelsPerRadW = widthPx / imageWidthRad
pixelsPerRadH = heightPx / imageHeightRad

imageCenterX = widthPx / 2
imageCenterY = heightPx / 2

(note that pixel size (in microns) and binning is assumed to be the same for both width and height here)
With star RA, Dec (s_ra, s_dec) and field center RA, Dec (c_ra, c_dec) in radians we get the standard coordinates:
stdX = cos(s_dec) * sin(s_ra - c_ra) / (cos(c_dec) * cos(s_dec) * cos(s_ra - c_ra) + sin(c_dec) * sin(s_dec))
stdY = (sin(c_dec) * cos(s_dec) * cos(s_ra - c_ra) - cos(c_dec) * sin(s_dec)) / (cos(c_dec) * cos(s_dec) * cos(s_ra - c_ra) + sin(c_dec) * sin(s_dec))

If rotation is assumed as zero, we now have everything we need to calculate the star positions:
starPixelX = pixelsPerRadW * stdX + imageCenterX
starPixelY = pixelsPerRadH * stdY + imageCenterY
starPixelX = width - starPixelX

To account for field rotation, we need to change it a little. Let's add the field rotation angle $r$.
starPixelX =  cos(r) * pixelsPerRadW * stdX + sin(r) * pixelsPerRadH * stdY + imageCenterX
starPixelY = -sin(r) * pixelsPerRadW * stdX + cos(r) * pixelsPerRadH * stdY + imageCenterY
starPixelX = width - starPixelX

With this, the star positions get rotated accordingly. At 90 degrees (cos(90deg) == 0, sin(90deg) == 1) we see that X effectively becomes Y and vice versa.
Conclusion
With a program that reads the RA, Dec coordinates of Tycho-2 catalog stars I drew the stars to an image using these equations, using the following parameters:

Pixel size (pxSize) = 3.8 microns
Image Width (widthPx) = 4656
Image Height (heightPx) = 3520
Center RA (c_ra) = 194.464 deg
Center Dec (c_dec) = 71.217 deg
Binning (bin) = 1
Focal length (fLen) = 25mm
Rotation (r) = -268 deg

Resulting in this image:

I then ran this through http://nova.astrometry.net astrometric solver, and successfully solved the image with the calculated (RA, Dec) center being: (194.461, 71.223).
As astrometry.net annotated with grid:

So there it is, projected stars from sphere to a flat plane.

> **Comments:**
> **username_1**: Thanks for sharing, this is really usefull read. Can you share the rest of it, how did you took the stars from the catalog, draw an image with them?  

---

### Answer by username_2 on 2021-04-18. Score: 2

This isn’t code for a full implementation, but you could do something like this:

1. Transform your RA, Dec coordinates (which are spherical polar coordinates, just all with the same $r$) to Cartesian $x, y, z$ coordinates. (The $r$ value you would use here is arbitrary, for example $r = 1$, and should be the same for all stars, not their real distances; you're just projecting them onto a sphere so you can do the transformation.)
2. Apply a [coordinate frame rotation](https://www.geeksforgeeks.org/computer-graphics-3d-rotation-transformations/) using your field-center RA, Dec coordinates (or perhaps their complements) as the rotation angles, so that the field center direction is the new $z$ axis.
3. Plot the resulting new $x, y$ coordinates, ignoring $z$.

You might have to do a further rotation of those $x, y$ coordinates to get the plot oriented the way you want, or maybe there’s a clever way to do that with the proper choice of angles in step 2.


---

