title: OpenGL ES orbit camera around object
body: <p>I want to orbit the camera around the object in OpenGL. Not quite happening. Here is my code:</p>
  
  <p>The object is the standard cube. </p>
  
  <pre><code>- (void)update {
  
      float aspect = fabsf(self.view.bounds.size.width / self.view.bounds.size.height);
  
      float radius = 10.0f;
      float startAngle = -3 * M_PI/4.0;
  
       float newX = 0.0f + radius *cos(phi)*sin(theta);
       float newY = 0.0f + radius *sin(phi)*sin(theta);
       float newZ = 0.0f + radius *cos(theta);
  
      GLKMatrix4 projectionMatrix = GLKMatrix4MakeLookAt(newX, 0.0, newZ 
                                                         0.0, 0.0, 0.0,
                                                         0.0, 1.0, 0.0);
  
  
      self.effect.transform.projectionMatrix = projectionMatrix;
  
      GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 0.0f);
     self.effect.transform.modelviewMatrix = modelViewMatrix;
  
  
  
  }
  
  
  
  -(void) viewPanned:(UIPanGestureRecognizer *) sender
  
  {
  
      CGPoint curTouch = [sender locationInView:self.view];
  
      if ([sender state] == UIGestureRecognizerStateBegan){
          oldX = curTouch.x;
          oldY = curTouch.y;
  
      }
  
  
      theta += (curTouch.x-oldX)*0.001f;
      phi   += (curTouch.y-oldY)*0.001f;
  
      oldX = curTouch.x;
      oldY = curTouch.y;
  }
  </code></pre>