Skip navigation

Maybe it’s because it’s Sunday afternoon and after coding all week at my day job my brain is pretty much spent by the time I get to my hobby coding.  Maybe it was that omelette from IHOP this morning.  I don’t know what it was, but for the life of me, this took me at least half an hour to figure out.

I’m a bright guy.  I took a number of senior level math courses in college.  I got an 800 on the GRE math section.  Yet this simple problem stumped me.

I’m not even going to go into details, I’m just going to give you the solution.  The only reason I’m posting this is because I couldn’t find the answer on Google, and when there’s something basic like this that I think would be important for the public to know and it isn’t the first hit on Google, I post it.

Here it is:

The red lines indicate how the hexagon is split into triangles.

For the unit hexagon (edge length 1) centered around (0,0), the vertex coordinates are:

0: (-0.5, -y)

1: (-1,0)

2: (-0.5, y)

3: (0.5, y)

4: (1,0)

5: (0.5, -y)

where y  = 0.5 * sqrt(3)

To turn this into a triangle strip, assuming CCW culling (in other words, verts are specified in clockwise order), the verts are:

{ 1, 2, 0, 3, 5, 4}

Note that if you are trying to draw a hexagonal grid then you don’t want to do it this way.

If you’re doing a grid, then the most efficient way is going to be to draw rows of strips, where each row is only a portion of each hexagon.  You’re on your own for that.  There’s a lot more google on that problem than this one.

Enjoy your f’ing hexagon.

About these ads

2 Comments

  1. Came across this after spending a few minutes thinking back to my undergrad graph theory and scribbling on a notepad, and I came to the same vertex order as you, but there’s something I don’t get:

    In a triangle strip, every three successive vertices are taken as a new triangle, and the triangle gets drawn such that when looking directly down its normal, the order of the vertices is clockwise. But in this ordering, the triangles alternate between being clockwise (1 2 0) and counterclockwise (2 0 3). Doesn’t this leave you with a hexagon where half the normals point one way, and half point the other?

  2. This is a topic that’s close to my heart… Many thanks!
    Where are your contact details though?


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: