title: Doing a matrix multiplication in reverse
body: <blockquote>
    <p>Follow-up for: <a href="https://stackoverflow.com/questions/30073616/calculating-world-coordinates-from-camera-coordinates/30074697#30074697">Calculating world coordinates from camera coordinates</a></p>
  </blockquote>
  
  <p>I'm multiplying a 2D vector with a transformation matrix (OpenGL's model-view matrix) to get world coordinates from my camera coordinates.</p>
  
  <p>I do this calculation like this:</p>
  
  <pre><code>private Vector2f toWorldCoordinates(Vector2f position) {
  
      glPushMatrix();
      glScalef(this.zoom, this.zoom, 1);
      glTranslatef(this.position.x, this.position.y, 0);
      glRotatef(ROTATION, 0, 0, 1);
  
      ByteBuffer m = ByteBuffer.allocateDirect(64);
      m.order(ByteOrder.nativeOrder());
      glGetFloatv(GL_MODELVIEW_MATRIX, m);
  
      float x = (position.x * m.getFloat(0)) + (position.y * m.getFloat(4)) + m.getFloat(12);
      float y = (position.x * m.getFloat(16)) + (position.y * m.getFloat(20)) + m.getFloat(28);
  
      glPopMatrix();
      return new Vector2f(x, y);
  }
  </code></pre>
  
  <p>Now I also want to do this vice-versa: calculate the camera coordinates for a position in the world. How can I reverse this calculation?</p>