So I was reading over something on this page (http://gamedeveloperjourney.blogspot.com/2009/04/point-plane-collision-detection.html)
The author mentioned
d = - D3DXVec3Dot(&vP1, &vNormal);
where vP1 is a point on the plane and vNormal is the normal to the plane. I’m curious as to how this gets you the distance from the world origin since the result will always be 0. In addition, just to be clear (since I’m still kind of hazy on the d part of a plane equation), is d in a plane equation the distance from a line through the world origin to the plane’s origin?
In the generic case the distance between a point
pand a plane can be computed bywhere
<a, b>is the dot product operationand where
p0is a point on the plane.When
nis of unity length the dot product between a vector and it is the (signed) length of the projection of the vector on the normalThe formula you are reporting is just the special case when the point
pis the origin. In this caseThis equality is formally wrong because the dot product is about vectors, not points… but still holds numerically. Writing down the explicit formula you get that
is the same as
Indeed a nice way to store a plane is to save the normal
nand the value ofk = <p0, n>wherep0is any point on the plane (the value ofkis independent on which point you choose of the plane).