Should you ever need to do such a thing, here is a quick guide to the process.
Suppose that you have a grid of
vertices that looks something like this:
* *
* *
* *
* *
* *
* *
* *
* *
...when all the
dots are connected, you’ll have a grid of
triangular faces. What you need is a way to determine which three vertices are used by an arbitrary
triangular face.
To do this, the vertices first need a
coordinate system so they can be identified:
0 1 2 3
0* 0*
0* 0*
1* 1*
1(*) 1*
2* 2*
2* 2*
3* 3*
3* 3*
A vertex can now be specified with
vertex location vX, vY, where vX is the column of the vertex, and vY is how far down the column the vertex is. For instance, the vertex in parentheses is (1, 1).
Now, the faces need a coordinate system:
0 1 2
* *
0 * *
1 * *
2 * *
3 * * X
4 * *
5 * *
* *
So now faces can be specified with a coordinate pair (fX, fY), where fX is the
column and fY is the row of the face. The face with the X in it is located at (2, 3).
This is all pretty easy, and probably didn’t
hurt your brain. Now, here’s the good bit -- how do you determine what the coordinates of the vertices are that belong to face (fX, fY)?
If fX and fY are
ODD:
* fX, (fY/2)
* fX + 1, (fY/2) + 1
* fX, (fY/2) + 1
If fX and fY are
EVEN:
*fX, (fY/2)
* fX + 1, (fY/2)
*fX, (fY/2) + 1
If fX is
ODD and fY is
EVEN:
*fX + 1, (fY/2)
* fX, (fY/2)
*fX + 1, (fY/2) + 1
If fX is
EVEN and fY is
ODD:
* fX + 1, (fY/2)
* fX, (fY/2) + 1
* fX + 1, (fY/2) + 1
A couple of hints to perhaps make this
intelligible:
-
Division shown is considered to be integer division -- that is, you drop any funny numbers after the
decimal place. So (3 / 2) = 1. Make sure you drop it, rather than
rounding.
- The little formulations are in the spots representing where the vertex is in the face. The *’s are the vertices, not
multiplication or anything like that.
Anyway, the
chance you’ll ever need to do this is pretty slim (and even if you do, it’s not too hard to figure out), but you never know...