Plane distance?

Started by
5 comments, last by GameDev.net 18 years, 1 month ago
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
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.
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.
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?
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.
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
Got an idea on how you would do physics?

This topic is closed to new replies.

Advertisement