@@ -32,19 +32,25 @@
/* builds all possible triangles */
int main(int argc, char *argv[])
{
- unsigned short x, bitop, mask;
+
+ /* figure = sequential ID for the figure we're drawing
+ edge = sequential ID for the edge of the figure, which we may or may not draw */
+ unsigned short figure, edge;
+
CONNECTIONS = connections(VERTICES);
POSSIBILITIES = (unsigned short) pow(2, CONNECTIONS);
- for (x = 0; x < POSSIBILITIES; x++)
+ /* iterate over total possible figures */
+ for (figure = 0; figure < POSSIBILITIES; figure++)
{
printf("%s\n", baseSvg);
- for (bitop = 0; bitop < CONNECTIONS; bitop++)
- {
- mask = ((unsigned short) pow(2, bitop)) & x;
- if (mask > 0)
+ /* in this figure, consider each potential edge */
+ for (edge = 0; edge < CONNECTIONS; edge++) {
+ /* is the edge's bit a 1 in the figure ID? */
+ if ((unsigned short) (1 << edge) & figure)
{
- printf("%s\n", lines[bitop]);
+ /* if so, draw it. */
+ printf("%s\n", lines[edge]);
}
}
printf("%s\n\n", endSvg);