title: How to rotate camera around object without centering to it
body: <p>I would like to make a camera rotate around object, but without shifting pivot to it's center. A good example I made with blender:
  <a href="https://imgur.com/VPWRJBC" rel="nofollow noreferrer">Link to gif</a> (In this example camera rotates around cursor, but it works as an example)</p>
  <p>So what I want is when I click a certain object, I want to rotate around it, but without centering camera pivot to objects position, basically retaining objects position on screen. I found many examples on rotating around objects center, but I can seem to find anything for my problem.</p>
  <p>Currently I have working camera rotation and movement, but I don't know how to approach this. I am working in OpenGL with Cinder framework.
  I would be grateful for a simple explanation on how would I be able to do it :)</p>
  <p>My current code:</p>
  <pre><code>void HandleUICameraRotate() {
  //selectedObj &lt;- object...has position etc..
  
  float deltaX = (mMousePos.x - mInitialMousePos.x) / -100.0f;
  float deltaY = (mMousePos.y - mInitialMousePos.y) / 100.0f;
  
  // Camera direction vector
  glm::vec3 mW = glm::normalize(mInitialCam.getViewDirection());
  bool invertMotion = (mInitialCam.getOrientation() * mInitialCam.getWorldUp()).y &lt; 0.0f;
  
  // Right axis vector
  vec3 mU = normalize(cross(mInitialCam.getWorldUp(), mW));
  
  if (invertMotion) {
      deltaX = -deltaX;
      deltaY = -deltaY;
  }
  
  glm::vec3 rotatedVec = glm::angleAxis(deltaY, mU) * (-mInitialCam.getViewDirection() * mInitialPivotDistance);
  rotatedVec = glm::angleAxis(deltaX, mInitialCam.getWorldUp()) * rotatedVec;
  
  
  mCamera.setEyePoint(mInitialCam.getEyePoint() + mInitialCam.getViewDirection() * mInitialPivotDistance + rotatedVec);
  mCamera.setOrientation(glm::angleAxis(deltaX, mInitialCam.getWorldUp()) * glm::angleAxis(deltaY, mU) * mInitialCam.getOrientation());
  }
  </code></pre>