Well, basically, p is a point on the plane and q is the point to test for. n is the identity normal. I may have flipped q and p.
Here’s how you’ll get that.
P is the point to test for and q is the point that lies somewhere on the plane. n is the normal, n0 the identity normal.
p-q is the vector that projects q to p. The cosine of the angle between that vector and the normal is:
cos a = (p-q)n / ((|p|-|q|)|n|)
Now, there’s also:
cos a = ankathete / hypotenuse
Where the hypotenuse is p-q and ankathete the distance vector (well the length of it).
So you’ll get:
d/(|p|-|q|) = (p-q)n / ((|p|-|q|)|n|)
d = (p-q)*n / |n|. Now a vector divided by itself is the normalized vector:
d = (p-q)*n0
Where the product is defined as:
ab = a0b0+a1b1+…+anbn for two n-component vectors.
[This message has been edited by Michael Steinberg (edited 02-06-2001).]