# Plane distance?

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

## 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 on other sites
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 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).

##### Share on other sites
Quote:
 Original post by PolyphemusI 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 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 on other sites
Quote:
Original post by jyk
Quote:
 Original post by PolyphemusI 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 on other sites
Got an idea on how you would do physics?

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

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013759
×