title: Does this code follow the definition of recursion?
body: <p>I have a piece of code which I am doubting it as a implementation of recursion by its definition. My understanding is that the code must call itself, the exact same function. I also question whether writing the code this way adds additional overhead which can be seen with the use of recursion. What are your thoughts?</p>
  
  <pre><code>class dhObject
  {
  public:
     dhObject** children;
     int numChildren;
     GLdouble linkLength; //ai 
     GLdouble theta; //angle of rot about the z axis
     GLdouble twist; //about the x axis
     GLdouble displacement; // displacement from the end point of prev along z
     GLdouble thetaMax;
     GLdouble thetaMin;
     GLdouble thetaInc;
     GLdouble direction;
  
     dhObject(ifstream &amp;fin)
     {
        fin &gt;&gt; numChildren &gt;&gt; linkLength &gt;&gt; theta &gt;&gt; twist &gt;&gt; displacement &gt;&gt; thetaMax &gt;&gt; thetaMin;
        //std::cout &lt;&lt; numChildren &lt;&lt; std::endl;
        direction = 1;
        thetaInc = 1.0;
        if (numChildren &gt; 0)
        {
           children = new dhObject*[numChildren];
           for(int i = 0; i &lt; numChildren; ++i)
           {
              children[i] = new dhObject(fin);
           }
        }
     }
  
     void traverse(void)
     {
        glPushMatrix();
        //draw move initial and draw
        transform();
        draw();
        //draw children
        for(int i = 0; i &lt; numChildren; ++i)
        {
           children[i]-&gt;traverse();
        }
        glPopMatrix();
     }
  
     void update(void)
     {
        //Update the animation, if it has finished all animation go backwards
        if (theta &lt;= thetaMin)
        {
           thetaInc = 1.0;
        } else if (theta &gt;= thetaMax)
        {
           thetaInc = -1.0;
        }
        theta += thetaInc;
        //std::cout &lt;&lt; thetaMin &lt;&lt; " " &lt;&lt; theta &lt;&lt; " " &lt;&lt; thetaMax &lt;&lt; std::endl;
        for(int i = 0; i &lt; numChildren; ++i)
        {
           children[i]-&gt;update();
        }
     }
  
     void draw(void)
     {
        glPushMatrix();
        glColor3f (0.0f,0.0f,1.0f);
        glutSolidCube(0.1);
        glPopMatrix();
     }
  
     void transform(void)
     {
        //Move in the correct way, R, T, T, R
        glRotatef(theta, 0, 0, 1.0);
        glTranslatef(0,0,displacement);
        glTranslatef(linkLength, 0,0);
        glRotatef(twist, 1.0,0.0,0.0);
     }
  };
  </code></pre>