# Calculating Distance for the frustum plane normals

This topic is 3629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Guys, I have calculated each plane's normal of the view frustum based on the verts of each of the 4 corners. However, the distance from the center is throwing me off. I can do a simple subtraction for the near/far planes. But the tilted left/right/top/bottom planes are throwing me off. Any ideas on how I can calculate those distances? Thanks Jeff.

##### Share on other sites
Finding the distance of a point from a plane is easy provided you have the equation of the plane. lighthouse3d has some nice reference material for this stuff.

##### Share on other sites
I *think* I have found a solution. I can do this...

float D = DotProduct(frontPlaneNrm,pos); //pos = position on the plane.

This seems to work. Can anyone confirm this is correct? Also, why would this work, because I thought the dot product gives me the angle between the vectors, nothing relating to distance.

Thanks
Jeff.

##### Share on other sites
MJP,

Great little tutorial, thanks! That helped a lot!

I still am curious on how the D = -DotProduct(N,p0); works. I still can't wrap my brain around that, I know it works, I just would like to know why it works :). I know the dot product returns the angle between two vectors, but the distance??

Jeff.

##### Share on other sites
Quote:
 I know the dot product returns the angle between two vectors, but the distance??
The dot product of two vectors can be interpreted geometrically in at least a couple of different ways:

1. As the cosine of the angle between the vectors, scaled by the product of the lengths of the two vectors.

2. As the length of the projection of vector A onto vector B, scaled by the length of vector B.

With a few example diagrams and a little trig, it should become clear why the two values described above are the same.

##### Share on other sites
The equation is actually
dist = N (dot) p + D

D = 0 assumes that the plane crosses through the origin.

##### Share on other sites
The equation is actually
dist = N (dot) p + D

D = 0 assumes that the plane crosses through the origin.

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631424
• Total Posts
3000008
×