title: About view matrix and frustum culling
body: <p>I was trying to determine if an object (sphere) is inside a view frustum. My strategy was first to get the view matrix:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>glm::lookAt(cameraPosition, lookAtPosition, cameraUp);
  </code></pre>
  
  <p>Where <code>cameraPosition</code> is the position of the camera, <code>lookAtPosition</code> is calculate by <code>cameraPosition + cameraDirection</code> and <code>cameraUp</code> is pretty much self-explanatory.</p>
  
  <p>After obtaining the view matrix, I calculate the 8 vertices of the frustum in the camera view, then multiply the inverse of the view matrix by each point to get the coordinate of them in the world space.</p>
  
  <p>Using these 8 points in the world space, I can construct the 6 planes by using cross products (so their normals will point inward). Then I take the dot product of the object vector (I get the vector by subtracting the object position with an arbitrary point on that plane) with the normal vector of each plane, if it is positive for all 6, I know it's inside the frustum.</p>
  
  <p>So my questions are:</p>
  
  <ul>
  <li>Is the camera view is always set at (0,0,0) and looking at the positive z direction?</li>
  <li>The view matrix transform the world view into the camera view, if I use the inverse of it to transform the camera view to the world view, is it correct?</li>
  </ul>
  
  <p>My frustum is opposite with my <code>cameraDirection</code> which causes nothing to be seen on the screen (but it still drawing stuff in the back of my camera).</p>