Distance from plane to point

Tom Wheeley (tomw@tsys.demon.co.uk)
Wed, 27 Mar 96 00:21:16 GMT

Date: Wed, 27 Mar 96 00:21:16 GMT
From: Tom Wheeley <tomw@tsys.demon.co.uk>
To: quake-editing@nvg.unit.no
Subject: Distance from plane to point

In article <Pine.HPP.3.91.960326112326.27185A-100000@embla.diku.dk> you write:

> On Tue, 26 Mar 1996, Tom Wheeley wrote:
>
> > In article <01BB1A6C.CBC201A0@ppp001.free.org> you write:
> >
> > > BTW, I'm having a little trouble understanding how to figure the =
> > > distance between (0,0,0) and a plane. If anyone could enlighten me on =
> > > this subject I be really grateful.
> >
> > Eh? How is your plane definition stored? id store their planes:
> >
> > r.n-hat = d (n-hat is an `n' with a `^' circonflex (sp?) on top.)
> >
> > Where `d' _is_ the distance from (0,0,0) and `r' is a general point, and `.'
> > is the scalar product (x1*x2+y1*y2+z1*z2). n-hat is the unit-vector stored
> > at the beginning of each plane entry in the BSP, it is followed by `d'.
> >
> > It is hard to help without knowing just what information you do have about
> > your plane.
>
> I couldn't quite follow that, so maybe I can be of help...
>
> You've got an equation for the plane
>
> a*x+b*y+c*z+d=0
>
> The distance from any point (x',y',z') to the plane should be given by
>
> sqrt(a*x'+b*y'+c*z'+d)

Err, I'm not certain (or uncertain) about that, as with x',y',z'=0,0,0,
you will get the distance as being sqrt(d), when it should be d, yes?

(Conversion from my notation)

r . n-hat = d

( x ) ( a )
( y ) . ( b ) = d (where a*a+b*b+c*c=1)
( z ) ( c )

ax + by + cz = d

or ax+by+cz-d=0

The change in sign of d doesn't matter, as it is a distance, not displacement.

For the distance to (0,0,0), I have the following:

ax+by+cz=d; d
dist = -----------------
sqrt(a*a+b*b+c*c)

Again, for the vectors defining the planes in the Quake bsp files, the
denominator is, handily, 1.

.splitbung

-- 
* TQ 1.0 * 101 New Names for Quake!
76.  Greedy angels