title: Implementing a hermite curve
body: <p>I am using <a href="http://cubic.org/docs/hermite.htm" rel="nofollow">this website on how to compute a hermite curve</a> under the heading <strong>The Math in Matrix Form</strong> to make a <em>hermite curve</em>.</p>
  
  <p>Here is my code so far...</p>
  
  <pre><code>// calculate hermite curve
      GLfloat S[4][1];
      GLfloat C[4][3] = {{height, 0, 0},
                         {0, radius, 0},
                         {0, 2 * radius, 0},
                         {-2 * height, 0, 0}};
      GLfloat h[4][4] = {{ 2,-2, 1, 1},
                         {-3, 3,-2,-1},
                         { 0, 0, 1, 0},
                         { 1, 0, 0, 0}};
  
      unsigned int rows;
      unsigned int cols;
      float val;
      for (int x = 0; x &lt; l_vertices; x++) {
          float segment = (float)x / l_vertices;
          S[0][0] = pow(segment, 3);
          S[1][0] = pow(segment, 2);
          S[2][0] = pow(segment, 1);
          S[3][0] = 1;
          GLfloat midwayArray[4][4] = {{ 0, 0, 0, 0},
                                       { 0, 0, 0, 0},
                                       { 0, 0, 0, 0},
                                       { 0, 0, 0, 0}};
          GLfloat finalArray[4][1] = { 0, 0, 0, 0};
          rows = 4;
          cols = 4;
          for (unsigned int i = 0; i &lt; rows; i++) {
              for (unsigned int j = 0; j &lt; cols; j++) {
                  for (unsigned int k = 0; k &lt; 1; k++) {
                      val = S[i][k] * h[k][j];
                      midwayArray[i][j] += val; 
                  }
              }
          }
  
          rows = 4;
          cols = 1;
          for (unsigned int i = 0; i &lt; rows; i++) {
              for (unsigned int j = 0; j &lt; cols; j++) {
                  for (unsigned int k = 0; k &lt; 4; k++) {
                      val = midwayArray[i][k] * C[k][j];
                      finalArray[i][j] += val;
                  }
              }
          }
          profileCurve[0][x] = finalArray[0][0];
          profileCurve[1][x] = finalArray[1][0];
          profileCurve[2][x] = finalArray[2][0];
      }
  </code></pre>
  
  <p>But I am getting mainly zeros for some reason. I think my matrix multiplication is not being done correctly.</p>
  
  <p>Also, just some information on how my code currently works. The first inner nested for loop is multiplying <strong>S</strong> and <strong>h</strong> just like the website says. Then the second inner nested for loop is multiplying the result of the previous matrix multiplication with <strong>C</strong> just like the website says.</p>
  
  <p>I think assign the result coordinates of the final array for that iteration of <code>x</code> to my <code>profileCurve</code> array which is going to store all the coordinates that make up the hermite curve.</p>