Jump to content
  • Advertisement
Sign in to follow this  
cold_heats_.--.

Point-Plane distance

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

Hello.
I am following WildBunny's tutorial regarding a simple physics engine :
http://www.wildbunny...es-for-dummies/
However, I have some trouble understanding this part :

"
for all particles i
{
for all planes j
{
distance = P.x*Planes[j].a + P.y*Planes[j].b + Planes[j].c;

if (distance < 0)
{
// collision responce
}
}
}

What this code is doing is finding, by projection, how much of the [color=#ff0000]vector from the plane to the particle is in the direction of the plane normal."

If every particle is determined by its (x,y) point, isn't this a vector from the origin to that point ?

This line :
"distance = P.x*Planes[j].a + P.y*Planes[j].b + Planes[j].c"
doesnt actually compute the dot product of the origin-point vector and plane normal rather than the plane-point(vector) and normal dot-product?

I drew some sketches so you can see my point.I am testing a particle against the plane who's normal isnt normalized .
[Sorry, I actually mean dot-product , not cross ] .

vsWSK.png
SonAB.png
I know there's a flaw in my reasoning, but I dont seem to get it . Edited by cold_heats_.--.

Share this post


Link to post
Share on other sites
Advertisement
"Plane" is a really odd name for a line on a plane. Actually, I think those objects should be called half-planes, because they seem to be the sets of points that satisfy Ax+By+C<0.

I don't understand your question at all. There is no cross product in 2D. All the code is doing is checking which particles seem to violate some constraints, with each constraint expressed as a half plane of forbidden positions.

Share this post


Link to post
Share on other sites
@alvaro , the author does specify they are actually lines when we refer to 2D.
My question is why does he say he computes the dot product between the vector-from-the-plane-to-point and plane-normal , if the line
" distance = P.x*Planes[j].a + P.y*Planes[j].b + Planes[j].c; " calculates the dot product between the vector-from-the-origin-to-point and the plane-normal ?

Share this post


Link to post
Share on other sites
We have already established that the author is not tremendously careful with language, so I wouldn't worry a whole lot about the exact wording. That said, he is basically right. The formula for the "the dot product between the vector-from-the-origin-to-point and the plane-normal" wouldn't have `+ Planes[j].c]' at the end.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!