Jump to content
  • Advertisement
Sign in to follow this  
Polyphemus

Plane distance?

This topic is 4492 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

Hi, Currently, I'm working on a 3d/game engine, and I think it's time to implement collision detection. I googled up this tutorial: http://www.flipcode.com/articles/article_basiccollisions.shtml, but because of my lack of knowledge of mathematics (I'm 15, and haven't learned a lot of useful stuff yet), I don't even understand the following:
int ClassifyPoint( CPlane3D *plane, CPoint3D *destPt )
  {
        scalar p = DotProduct( plane->normal, destPt ) + plane->distance;

        if( p > 0.0f ) return PLANE_FRONT;
        else
        if( p < 0.0f ) return PLANE_BACK;

        return PLANE_COINCIDE;
  }
so my question: what is the plane distance (or it could be the scalar distance, don't know what that is)? Thanks for your time, Polyphemus

Share this post


Link to post
Share on other sites
Advertisement
Imagine a plane somewhere in 3-space with unit-length normal n. The 'plane distance' is the (signed) distance to the plane from the origin along this normal, 'signed' because whether this value is considered to be the positive or negative distance depends on whether you're using the plane representation p.n = d, or p.n + d = 0. It looks like your example uses the latter, so d is the negative distance to the plane from the origin along the plane normal.

Share this post


Link to post
Share on other sites
I see... well, not completely, but I get the general idea. Thank you :)

I have one problem left now... I only have a very very faint idea of how I should calculate this. Could somebody tell me how to do it? (I prefer code, but anything is fine).

Again, thanks for your time.

Share this post


Link to post
Share on other sites
Quote:
Original post by Polyphemus
I have one problem left now... I only have a very very faint idea of how I should calculate this.
What is it that you need help calculating?

Share this post


Link to post
Share on other sites
Lets say you have a point in your plane, call it Q. Lets say you have another point, call it P. The vector from Q to P can be calculated as:
v = P - Q

To check this vector against the normal vector n, the dot product is used:
r = dot(n, v)

The dot product is positive, if both vectors point (more or less) into the same direction, is zero if they are perpendicular, and is negative if they point (again more or less) away from each other.

The calculation of the dot product may be split:
r = dot(n, v) = dot(n, P-Q) = dot(n, P) - dot(n, Q)

The part "dot(n, Q)" is the distance of the plane from the origin. You can use any point Q (which is part of the plane) for this calculation.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Quote:
Original post by Polyphemus
I have one problem left now... I only have a very very faint idea of how I should calculate this.
What is it that you need help calculating?


I'm 15 years old, and I haven't learned a lot of mathematics at school yet. I hope you understand I would love to know everything myself, and I'm trying to do as much research as I can, but what takes 6 hours for me takes 1 minute for you.

Thanks a lot, both of you, because of your help I finished my collision detector a lot faster than expected :D

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Got an idea on how you would do physics?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!