Geodesic Grid – Part 2

Where to start?

Well, the first thing we need to do is create an Icosahedron.  We need the vertices and the indices of the faces.  Finding the cartesian coordinates of the vertices is simple enough.  Once you’ve got the coordinates, you just need to use a little brain power to come up with the indices.

First off, I’ve created a class called Icosahedron.  This class will hold our data about the icosahedrons we create, such as the vertices and indices.  Here’s the code

public class Icosahedron
{
    public byte Frequency;
    public VertexPositionNormal[] Vertices;
    public int[] Indices;
    public Wireframe Wireframe;
}

The observant will note that VertexPositionNormal and Wireframe are not types included in the XNA framework.  These are custom types, and the code for them is included in the zip.  The Wireframe class just holds information about vertices and indices used to draw the lines of a wireframe mesh.  VertexPositionNormal is a vertex with a position and a normal.  Nothing too difficult to understand about either of them.

Backstory

An icosahedron is made up of 20 triangle faces.  Each of the faces of the icosahedron is what Joe Clinton called a Principle Polyhedral Triangle (PPT). [1] Our task now is to subdivide each of these PPTs into smaller triangles.

Joe lists multiple methods of subdividing the PPTs, but I will only focus on the method he refers to as “Method 1″ or “Alternate.”  With this method, each side of a PPT is split into n frequency parts. [2]

Singleton Factories

Now that we’ve laid out what makes up an Icosahedron, we have to fill in that data.  I’ve chosen to go the route of Singleton Factories to create the geometry.  The reason I did so was to allow me to create different factory types to test different methods of creation.

The first thing I did was create an interface that all of my icosahedron factories would implement.

public interface IIcosahedronFactory
{
    Icosahedron CreateIcosahedron(byte frequency);
}

The icosahedron factories will all have the CreateIcosahedron method, that takes a byte frequency as an input parameter.  The frequency is the number of times each side of a PPT will be split, as mentioned before.

As such, I’ve created IcosahedronFactory, which handles creation of icosahedrons.  It uses Nick Gravelyn’s useful Singleton class as its base.  With IcosahedronFactory, all you’ve got to do is call CreateIcosahedron, pass it a number, and out comes your new icosahedron geometry.

Behind the scenes, what it does is take each PPT from an initial icosahedron and subdivides each side of the PPT.  It then fills in the “center” of the PPT with new triangles.  After that is done, it goes through the vertices and indexes them while removing duplicates.

When all is said and done, you should end up with an icosahedron with:

V = 10 * u2 + 2
F = 20 * u2
E = 30 * u2

where V is the number of vertices, F is the number of faces, E is the number of edges, and u is the frequency of subdivision. [3]

So, if you used a frequency of 4, you’d get an icosahedron with 162 vertices, 320 faces, and 480 edges.  It would look something like this:

Next Time

Try to get a grasp on what is happening in the IcosahedronFactory class.  Next, in Part 3, I’ll explain how a dual polyhedron is generated from an Icosahedron, and what that means for our Geodesic Grid.

References

  1. ^ Clinton, Joe, “Geodesic Math” pg. 5
  2. ^ Clinton, Joe, “Geodesic Math” pg. 9
  3. ^ Clinton, Joe, “Geodesic Math” pg. 8

Solution Files

GeodesicExample_Part-2.zip

About these ads

3 thoughts on “Geodesic Grid – Part 2

  1. Pingback: Geodisc Truncated Icosahedron « Sgt. Conker

  2. The Joe Clinton’s work that you link to is not available anymore it seems. Could you be so kind as to source another version?

    Tam

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: