Jump to content
  • Advertisement
Sign in to follow this  
webjeff

Calculating Distance for the frustum plane normals

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
The equation is actually

dist = N (dot) p + D


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

Share this post


Link to post
Share on other sites
The equation is actually

dist = N (dot) p + D


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!