Back to July Calendar Previous Entry Next Entry→

July, 16, 2005

 

So it occurs to me that the classic Sierpinski Gasket can be generated more simply by drawing in only one color and not drawing the middle triangle at all.  Modifying the sierpinsk() function as follows we get the classic gasket:

 

 

void sierpinsk(GLfloat *a, GLfloat *b, GLfloat *c, int m) {
   //Triangle subdivision using vertices
   GLfloat v[3][2]; //starting triangle for all furtherly divided:
   if(m>0) {
      for(int j=0;j<2;j++) {
         v[0][j] = (a[j] + b[j])/2;
         v[1][j] = (b[j] + c[j])/2;
         v[2][j] = (a[j] + c[j])/2;
      }
      glColor3f(0.0,0.0,0.0);
      sierpinsk(a, v[0], v[2], m-1 );
      sierpinsk(v[0], b, v[1], m-1 );
      sierpinsk(v[2], v[1], c, m-1 );
   }
   else
      triangle(a,b,c);
}

 

 

 

Well, gotta go to Carlsbad, so that’s about it for today.  A quick thought on Karl Rove, or, Turdblossom, as GW calls him: according to the Frontline piece on him,  "Karl Rove is born in Denver in 1950. His father, Louis, is a mineral geologist and travels extensively for work, and the family moves several times during Rove's childhood. At age 9, Rove is a vocal supporter of Richard Nixon's presidential campaign -- so vocal, in fact, that an older girl, a would-be Kennedy voter, beats him up."  Now, who was this girl?  Did she sow seeds of vengeance, or just leave a needed job half done?

 

When I return to this hollowed log, I hope to get the canoe moving.  Chapter 3 of Angel's OpenGL Primer is titled, "Interaction and Animation."  and starts iwth a discussion of resizing a clipping box and adjusting the viewport. and seems to involve some casting.  Here's a typical reshape callback:

 

glutReshapeFunc(myreshape);

 

  where myreshape() is given by

 

GLsizei ww, hh;

 

void myreshape(GLsizei w, GLsizei h) {

  

   // adjust clipping box

   glMatrixMode(GL_PROJECTION);

   glLoadIdentity();

   if (w <= h)

      gluOrtho2D(-2.0,2.0,-2.0*(GLfloat) h / (GLfloat) w, 2.0*(GLfloat) h / (GLfloat) w);

   else

      gluOrtho2D(-2.0*(GLfloat) w / (GLfloat) h, 2.0*(GLfloat) w / (GLfloat) h, -2.0, 2.0);

   flMatrixMode(GL_MODELVIEW);

   // adjust viewport

   flViewport(0,0,w,h);

   // set global size for use by drawing routine

   ww = w;

   hh = h;

}