title: Stepping between spherical coords (OpenGL, C++, GLUT)
body: <p>I have defined 2 points on the surface of a sphere using spherical coordinates.</p>
  
  <pre><code>// define end point positions
  float theta_point_1 = (5/10.0)*M_PI;
  float phi_point_1 = (5/10.0)*2*M_PI;
  float x_point_1 = Radius * sin(theta_point_1) * cos(phi_point_1);
  float y_point_1 = Radius * sin(theta_point_1) * sin(phi_point_1);
  float z_point_1 = Radius * cos(theta_point_1);
  
  float theta_point_2 = (7/10.0)*M_PI;
  float phi_point_2 = (1/10.0)*2*M_PI;
  float x_point_2 = Radius * sin(theta_point_2) * cos(phi_point_2);
  float y_point_2 = Radius * sin(theta_point_2) * sin(phi_point_2);
  float z_point_2 = Radius * cos(theta_point_2);
  
  
  // draw end points
  void end_points ()
  {
      glColor3f (1.0, 1.0, 1.0);
      glPointSize(25.0);
      glBegin(GL_POINTS);
      glVertex3f(x_point_1,y_point_1,z_point_1);
      glVertex3f(x_point_2,y_point_2,z_point_2);
      glEnd();
  }
  </code></pre>
  
  <p>To step between the two points, I do the following:</p>
  
  <ol>
  <li>find the difference between theta_points_1,2 and phi_points_1,2</li>
  <li>divide the differences by 'n' (yielding 's')</li>
  <li>redraw 'n' times, while stepping up the theta and phi by 's' each time</li>
  </ol>
  
  <p>In the following, I've defined the differences between my theta and phi values, divided them, and then redraw them.</p>
  
  <pre><code>// begining spherical coords
  float theta_point_1_value=5;
  float phi_point_1_value=5;
  
  // ending sperical coords
  float theta_point_2_value=7;
  float phi_point_2_value=1;
  
  // dividing the difference evenly
  float step_points=30;
  float step_theta = 2/step_points;
  float step_phi = 4/step_points;
  
  // step between spherical coordinates
  void stepping_points ()
  {
      glColor3f (1.0, 0.0, 0.0); 
      for (int i = 1; i &lt; step_points; i++)
      {
          float theta = (theta_point_1_value/10.0)*M_PI;
          float phi = (phi_point_1_value/10.0)*2*M_PI;
          float x = Radius * sin(theta) * cos(phi);
          float y = Radius * sin(theta) * sin(phi);
          float z = Radius * cos(theta);  
          glPushMatrix();         
          glTranslatef(x,y,z);
          glutSolidSphere (0.05,10,10);
          glPopMatrix(); 
      }  
      glEnd();
  }
  </code></pre>
  
  <p>Now I understand, this displays 30 solid spheres at the same position. Because I have NOT included 'step_theta' or 'step_phi' in any of the redraws.</p>
  
  <p>And that is the root of my question. How do I employ 'step_theta' and 'step_phi' in my redraws?</p>
  
  <p>What I want to do is say something like this at the top of my 'for' loop:</p>
  
  <pre><code>    for (int i = 1; i &lt; step_points; i++)
      {
          float theta_point_1_value = (theta_point_1_value+step_theta);
          float phi_point_1_value = (phi_point_1_value+step_phi);
  
          float theta = (theta_point_1_value/10.0)*M_PI;
          float phi = (phi_point_1_value/10.0)*2*M_PI;
          float x = Radius * sin(theta) * cos(phi);
          float y = Radius * sin(theta) * sin(phi);
          float z = Radius * cos(theta);  
          glPushMatrix();         
          glTranslatef(x,y,z);
          glutSolidSphere (0.05,10,10);
          glPopMatrix(); 
      } 
  </code></pre>
  
  <p>The above will redraw 30 solid spheres, but they don't show between my defined end points. It's pretty clear that either my math or syntax is screwy (or more than likely, both are).</p>