*Note 9/3/2010: Redone all of the diagrams*

**If you are just looking for a download link to the program, here it is. To run, save as Stellar.jar (Java is required)**

As school has been over for more than a week now, I’ve had time to (among other things) study geometry. I’m just spending an hour or two every day working through variousÂ exercisesÂ in Geometry Revisited.

This blog post is long overdue; it had been sitting in my drafts section with a few sentences written since the middle of April. Maybe it’s still useful now, maybe not. Anyways.

I myself am not in IB, because of my hatred of being forced to do copious and tedious amounts of homework. Many of my friends, however, take IB math. One famous project in IB math (not only in my school, but also in other schools) is a large project known as the *math portfolio*. From what I’ve heard, this consists of a dozen or so pages of writeup on some extended problem.

I first heard about the existence of such a project when a few of my friends asked me for help on it. The project was related to ‘stellar numbers’; a picture of the assignment can be found here. The problem itself seems rather trivial, thus I don’t feel it necessary to discuss it in this blog post.

My investigations here, although inspired by this assignment, is only marginally related to the assignment itself. The end product to be handed in for grades was supposed to include diagrams. However, it isn’t so easy to draw diagrams of stars (see above image) either by hand or on the computer. I saw many of my friends hastily put together their diagrams of stars using Powerpoint or MS Word, using the line and circle tools and a heck lot of copy-and-pasting. The result, unsurprisingly, is messy and inexact. One friend of mine wrote a computer program to output Latex code to draw the stars; the details of how this is done is something I consider more difficult and interesting than the project itself.

Keeping along with my theme of geometry this week, it is useful to figure out the geometry of star polygons before writing programs to generate them.

### Some geometric constructions

Consider the five sider star (fig.1):

We can see that the five corners of the star, *ABCDE*, are the same distance from the center *K* of the star. This means the five points lie on a circle; furthermore the distances between the corners are the same.

A similar phenomenon occurs with the five points between the corners, *FGHIJ*. They, too, lie on a circle centered around *K*.

Let us call the radius of the larger circle *r*, and the radius of the smaller circle *i*. Any star can be built around the framework of two circles. For example, our five pointed star (fig.2):

There is, however, one more characteristic present in star polygons that we neglected in the above diagram. It is that we chose the values of *r* and *i* pretty much arbitrarily.

Notice that in (fig.1), the sides *EF* and *GB* are parallel. It can be shown geometrically that if parallel, *EF* and *GB* are also concurrent. In (fig.2), *EF* and *GB* are not parallel nor concurrent.

Although any values of *i* and *r* for are enough to produce a star, it is necessary to further adjust the ratio between *i* and *r* in order to produce a correct *star polygon*.

Let us denote *n* to mean the number of points of a star, and *d* to denote the *density* of a star.

What do we mean by density? In order to define density, we will take a step back and take a look at alternative ways that star polygons can be constructed.

At present we are looking at star polygons as points on two distinct circles joined together with alternating line segments. Here is a completely different way of presenting it (fig.3):

Points *ABCDE *are spread equally on a circle. For the five points, every *two *points are connected by a line. We define density to be this number: the density for this star is 2.

It is possible, perhaps easier, to implement a drawing routine this way. However, by doing this we would have to erase the lines *FGHIJ*, which seems straightforward but is troublesome in implementation. We are going to stick to the two circles paradigm.

If , then our ‘star’ would be degenerate; it would merely be a *n*-sided polygon. On the other hand, we assume that the inner circle has positive radius, thus,

For any integer *n* with , the maximum value of *d* is given by:

Next is finding a way to express the ratio between the radii in terms of *n* and *d*.

Here we combined the previous two diagrams, and added some new lines. Since our star contains so much symmetry, what follows can be extended to all corners of the star, and also to stars with different densities and number of corners.

Let us call the angle to be *x*, which is of the circle, or radians.

Let *y* be the angle such that

.. whence here , therefore .

As is isosceles, , and ; therefore

.. whence here .

Next, , in our case , thus the measure of can be found:

In our case .

By the sine law in ,

Or,

Simplifying, we get

We defined that and that , thus we write *y*:

And that brings us to the final formula:

Evaluating it for our star, we find that if , then .

### Implementation in Java

Now that we have the math done, it is a fairly easy programming exercise to implement this as a java application. Here’s what I came up with after ~2 hours of hacking in Netbeans (animated gif):

This may be useful to future people doing the same assignment (if it ever gets assigned again), or with modifications it may be useful for other purposes too.

To use it, adjust the settings, take a screenshot, crop it, and it may be necessary to further edit it in photoshop.

Without further ado, here’s the application as a jar file:

*(broken link removed)*

Or the source as a Netbeans project:

Do whatever you want with them, and have fun!