<p>It is  common that the camera is pointing towards negative Z, in order to satisfy right hand rule. So you need to know the convention.</p>

<p>As for theinverse matrix of the camera matrix. Sort of yes. You can do it. However the camera matrix is a homogeneous space. While generally our other matrixes are affine spaces. If you take care of the distinction and do the proper camera divide, if tge camera needs one. Then yes you could do that.</p>

CC BY-SA 4.0
2019-10-03T20:22:01.893Z
2019-10-03T20:22:01.893Z
joojaa
<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><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>

<opengl>
About view matrix and frustum culling
Tien Dinh
# About view matrix and frustum culling

(Asked by: username_0 on 2019-10-03)

I was trying to determine if an object (sphere) is inside a view frustum. My strategy was first to get the view matrix:

```
glm::lookAt(cameraPosition, lookAtPosition, cameraUp);

```

Where `cameraPosition` is the position of the camera, `lookAtPosition` is calculate by `cameraPosition + cameraDirection` and `cameraUp` is pretty much self-explanatory.

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.

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.

So my questions are:

* Is the camera view is always set at (0,0,0) and looking at the positive z direction?
* 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?

My frustum is opposite with my `cameraDirection` which causes nothing to be seen on the screen (but it still drawing stuff in the back of my camera).

**Tags:** opengl


---

## 1 answers

### Answer by username_1 on 2019-10-03. Score: 1

It is common that the camera is pointing towards negative Z, in order to satisfy right hand rule. So you need to know the convention.

As for theinverse matrix of the camera matrix. Sort of yes. You can do it. However the camera matrix is a homogeneous space. While generally our other matrixes are affine spaces. If you take care of the distinction and do the proper camera divide, if tge camera needs one. Then yes you could do that.


---

