# AMBER Archive (2009)Subject: Re: [AMBER] Need help with point to plane distance calculation in nab

From: M. L. Dodson (activesitedynamics_at_comcast.net)
Date: Thu Jan 08 2009 - 13:16:51 CST

IN SUK JOUNG wrote:
> My rough calculation gives...
>
> When the point is (x,y,z), distance = abs( ( z - Ax - By - C ) / ( A^2 + B^2
> + 1 ) )
>
> You should check if it is valid by yourself.
>

Thank you very much. Could I impose on you some more to describe in
words where the two terms come from? In other words, how you derived
the formula (or give me a reference if this is a well known
relationship)? I would be grateful for this as I want to understand
how it comes about. This will be a (minor) point in a publication,
and I need to justify the algorithm.

Also, let me be sure I understand your nomenclature: In the expression
( z - Ax - By - C ), are x, y, and z the coordinates of the single
atom (given by aex2) that I want to know the distance from the plane
for? In other words, what I am calling X and Y? (Z would be the z
coord for aex2.)

Hope I am clear.
Thanks again.

Bud Dodson

> On Thu, Jan 8, 2009 at 11:39 AM, M. L. Dodson <
> activesitedynamics_at_comcast.net> wrote:
>
>> Hello all,
>>
>> I'm having a brain cramp coming up with the correct algebra for an
>> algorithm giving the distance from a point to a plane along a normal
>> to the plane. In nab, I can calculate the least squares best fit of a
>> plane of form z = Ax + By + C to a series of atomic positions
>> (represented by a nab atom expression, complete_aex1, in the molecule
>> mol) by using:
>>
>> plane(mol, complete_aex1, A, B, C),
>>
>> where complete_aex1 is an atom expression identifying the atoms whose
>> positions are to be fit by the plane.
>>
>> I want to calculate the distance from that plane to another atom
>> (given by aex2) ALONG A NORMAL to the plane.
>>
>> I need the correct POINT in the plane where the normal intersects. At
>> first I set the x and y coords of the POINT to be the x and y coords
>> of the atom given by aex2, say X and Y. Then set z coord of the POINT
>> to be z = AX + BY + C. Then I calculated the distance between the
>> position of atom aex2 and that point in the plane. But this (pretty
>> clearly, it seems to me), is NOT along a normal to the plane.
>>
>> Can any of you geometers out there hit me with a clue bat? An
>> algorithm will do. You do not need to know nab to answer.
>>
>> Thanks,
>> Bud Dodson

```--
M. L. Dodson