Wednesday, November 30, 2011

How many stars in the sky?

Answer: About 3.3 million.

Ever since the new star field came out a year or so ago, I've been vaguely impressed at the number of stars that appear when you zoom the camera in. It has to be a repeating texture of some sort, of course, but it's still pretty impressive.

Today I decided to find out very approximately how many stars are in the sky box.

Step 1: Get a nice linear ship and an aesthetically pleasing patch of sky.


Step 2: With the camera aligned with the axis of the ship, zoom in.

Step 3: Put the cursor at one side of the screen. Right-click and drag the cursor to the other side of the screen. Zoom out. Using the ship as a reference, estimate how many degrees the camera has turned.

That looks like about 45 degrees to me.

Step 4: Find out how the width of the screen compares to the width of the arc covered when dragging the mouse across the screen.

This is accomplished by zooming in, placing the cursor at one edge of the screen, dragging the camera one screen-width and taking a screenshot. The distance in pixels from the cursor to the edge of the screen, divided by the monitor width in pixels, is the number of screen-widths in a 45 degree arc.

Screenshots don't save the cursor position, but I was able to use UI elements as landmark. The answer is about 160 pixels, so with a 1650x monitor there are 10.3 screen-widths in a 45 degree arc.

Step 5: Find the surface area of the sky sphere, measured in screen-widths.

10.3 screen-widths is 45 degrees. A circle is 360 decrees. (360/45)*10.3 gives us a circumference of 82.4 screen-widths.

Putting 'sphere circumference 82.4' into wolfram tells us that the surface area of the sphere is 2161.

(that's 2161 1650x1650 pixel squares)

So all we have to do is find out how many stars are in a 1650x1650 square. But that's a lot of stars, so instead we'll find out how many stars are in 1/10 that area.

Sqrt(1650^2/10)=521

So we take a zoomed-in screenshot, mark out a 521^2 pixel square, count the stars and multiply the answer by 2161*10.


That's 152 stars. 152*10*2161=3.3 million stars... within a fairly wide margin of error.

1 comment:

  1. While I was reading this, Rosey was giving me the big bang.

    ReplyDelete